Beispiel #1
0
        public void OnUpdated(EntityJs.Client.Events.EntityEventArgs e)
        {
            BuildingEntities db = (BuildingEntities)e.Context;
            DateTime         date;
            User             user = db.CurrentUser;

            if (RemindDate.HasValue)
            {
                date       = RemindDate.Value.Date;
                RemindDate = RemindTime.IsNotNullOrEmpty() ? date.Add(TimeSpan.Parse(RemindTime)) : date;
            }

            date = DateTime.Now;
            IncidentUser iu = db.IncidentUsers.FirstOrDefault(val => val.IncidentID == this.ID && val.UserID == user.ID);

            if (Read && iu == null)
            {
                iu = new IncidentUser()
                {
                    ChangeDate = date, ChangerID = db.CurrentUser.ID, CreateDate = date, CreatorID = db.CurrentUser.ID, Done = true, Incident = this, UserID = db.CurrentUser.ID
                };
                db.IncidentUsers.AddObject(iu);
            }
            if (iu != null && iu.Done != Read)
            {
                iu.Done       = Read;
                iu.ChangerID  = user.ID;
                iu.ChangeDate = date;
            }
        }
Beispiel #2
0
        public void OnInserted(EntityJs.Client.Events.EntityEventArgs e)
        {
            BuildingEntities db = (BuildingEntities)e.Context;

            if (RemindDate.HasValue)
            {
                DateTime date = RemindDate.Value.Date;
                RemindDate = RemindTime.IsNotNullOrEmpty() ? date.Add(TimeSpan.Parse(RemindTime)) : date;
            }

            if (Read)
            {
                DateTime     date = DateTime.Now;
                IncidentUser iu   = new IncidentUser()
                {
                    ChangeDate = date, ChangerID = db.CurrentUser.ID, CreateDate = date, CreatorID = db.CurrentUser.ID, Done = true, Incident = this, UserID = db.CurrentUser.ID
                };
                db.IncidentUsers.AddObject(iu);
            }
        }