114 lines
4.4 KiB
C#
114 lines
4.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.Mvc;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using EnVisage.Code;
|
|
using System.Web.Script.Serialization;
|
|
|
|
namespace EnVisage.Models
|
|
{
|
|
public class NotificationModel : IBaseModel<Notification>
|
|
{
|
|
|
|
[Display(Name = "Title")]
|
|
[Required]
|
|
public string title { get; set; }
|
|
[Display(Name = "Description")]
|
|
[Required]
|
|
public string description { get; set; }
|
|
public Guid? IdinLink { get; set; }
|
|
public string WorkFlowEntityName { get; set; }
|
|
public string WorkFlowState { get; set; }
|
|
public string WorkFlowLinkName { get; set; }
|
|
public Guid Id { get; set; }
|
|
public Guid ParentId { get; set; }
|
|
public DateTime? ExpiresOnDate { get; set; }
|
|
[Display(Name ="Link")]
|
|
public Uri link { get; set; }
|
|
public bool DeleteOnPageView { get; set; }
|
|
public NotificationType type { get; set; }
|
|
public NotificationGroupType NotificationGroup { get; set; }
|
|
|
|
public List<NotificationControlModel> Actions { get; set; }
|
|
|
|
public DateTime NotificationDate { get; set; }
|
|
|
|
public bool NotificationViewed { get; set; }
|
|
|
|
public int NotificationHours { get; set; }
|
|
public NotificationModel(Notification dbObj, EnVisageEntities context)
|
|
{
|
|
if (dbObj == null)
|
|
throw new ArgumentNullException();
|
|
|
|
|
|
if (dbObj.ParentId.HasValue)
|
|
ParentId = dbObj.ParentId.Value;
|
|
title=dbObj.Title;
|
|
description = dbObj.Description;
|
|
if (dbObj.Link != null)
|
|
link = new Uri(Code.Session.AbsoluteUrl.NotificationPassthruUrl(dbObj.Id, context)); //new Uri(dbObj.Link);
|
|
NotificationGroup =(NotificationGroupType)dbObj.NotificationGroup;
|
|
type = (NotificationType)dbObj.NotificationType;
|
|
Id = dbObj.Id;
|
|
NotificationDate = dbObj.NotificationDate;
|
|
NotificationViewed = dbObj.NotificationViewed;
|
|
TimeSpan variable = DateTime.Now - dbObj.NotificationDate;
|
|
NotificationHours = Convert.ToInt32(Math.Floor( variable.TotalHours));
|
|
this.IdinLink = dbObj.IdinLink;
|
|
this.WorkFlowLinkName = dbObj.WorkFlowLinkName;
|
|
this.WorkFlowState = dbObj.WorkFlowState;
|
|
this.WorkFlowEntityName = dbObj.WorkFlowEntityName;
|
|
this.DeleteOnPageView = dbObj.DeleteOnPageView.HasValue?dbObj.DeleteOnPageView.Value:false;
|
|
this.ExpiresOnDate = dbObj.ExpiresOnDate;
|
|
}
|
|
public NotificationModel() { }
|
|
public void CopyTo(Notification dbObj)
|
|
{
|
|
if (dbObj == null)
|
|
throw new ArgumentNullException();
|
|
dbObj.ParentId = ParentId;
|
|
dbObj.Title = title;
|
|
dbObj.Description = description;
|
|
if (link != null)
|
|
dbObj.Link = link.ToString();
|
|
dbObj.NotificationGroup = (int)NotificationGroup;
|
|
dbObj.NotificationType = (int)type;
|
|
dbObj.NotificationDate = NotificationDate;
|
|
dbObj.NotificationViewed = NotificationViewed;
|
|
dbObj.IdinLink = this.IdinLink;
|
|
dbObj.WorkFlowState = this.WorkFlowState;
|
|
dbObj.WorkFlowLinkName = this.WorkFlowLinkName;
|
|
dbObj.WorkFlowEntityName = this.WorkFlowEntityName;
|
|
dbObj.DeleteOnPageView = this.DeleteOnPageView;
|
|
dbObj.ExpiresOnDate = this.ExpiresOnDate;
|
|
}
|
|
public NotificationModel clone()
|
|
{
|
|
NotificationModel m = new NotificationModel()
|
|
{
|
|
ParentId = this.ParentId,
|
|
title = this.title,
|
|
description = this.description,
|
|
link = this.link,
|
|
NotificationGroup = this.NotificationGroup,
|
|
type = this.type,
|
|
NotificationDate = this.NotificationDate,
|
|
NotificationViewed = this.NotificationViewed,
|
|
IdinLink = this.IdinLink,
|
|
WorkFlowLinkName = this.WorkFlowLinkName,
|
|
WorkFlowState = this.WorkFlowState,
|
|
WorkFlowEntityName = this.WorkFlowEntityName,
|
|
DeleteOnPageView = this.DeleteOnPageView,
|
|
ExpiresOnDate = this.ExpiresOnDate
|
|
};
|
|
return m;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|