Exemplo n.º 1
0
 public void AfterSave(bool isUpdate)
 {
     if (this is ICriticalEntity)
     {
         // EntityHistory tablosuna bu işlemi loglayalım
         if (!isUpdate)
         {
             EntityHistory eh = new EntityHistory()
             {
                 Details = "",
                 EntityName = this.GetType().Name,
                 EntityId = this.Id,
                 InsertDate = DateTime.Now,
                 InsertUserId = CinarContext.ClientUser.Id,
                 Operation = CRUDOperation.Insert
             };
             eh.Save();
         }
         else
         {
             if (!string.IsNullOrEmpty(changes))
             {
                 EntityHistory eh = new EntityHistory()
                 {
                     Details = changes,
                     EntityName = this.GetType().Name,
                     EntityId = this.Id,
                     InsertDate = DateTime.Now,
                     InsertUserId = CinarContext.ClientUser.Id,
                     Operation = CRUDOperation.Update
                 };
                 eh.Save();
             }
         }
     }
 }
Exemplo n.º 2
0
        public virtual void Delete()
        {
            if (CinarContext.Db == null)
                throw new Exception("Cannot reach context database");

            if (this is ICriticalEntity)
            {
                // EntityHistorytablosuna bu işlemi loglayalım
                EntityHistory eh = new EntityHistory()
                                       {
                                           Details = this.SerializeToString(),
                                           EntityName = this.GetType().Name,
                                           EntityId = this.Id,
                                           InsertDate = DateTime.Now,
                                           InsertUserId = CinarContext.ClientUser.Id,
                                           Operation = CRUDOperation.Delete
                                       };
                eh.Save();
            }

            CinarContext.Db.ExecuteNonQuery("delete from " + this.GetType().Name + " where Id={0}", this.Id);
        }