Пример #1
0
 protected override void Seed(PoliceServer.Models.PoliceContext context)
 {
     try
     {
         InitialUser(context);
         context.SaveChanges();
     }
     catch (Exception ex)
     {
         Log.Error("Seed Method Exception: " + ex.Message);
     }
 }
Пример #2
0
        public object Clone()
        {
            PoliceContext  contex       = ContextCreator.GetInstance().GetContext();
            DbSet          set          = contex.Set(this.GetType());
            AbstractEntity clonedEntity = set.Find(this.Id) as AbstractEntity;

            contex.Entry(clonedEntity).State = EntityState.Detached;
            if (clonedEntity == null)
            {
                //TODO
                //throw new UserInterfaceException(27701, String.Format("امکان کپی کردن {0} با شناسه ی {1} وجود ندارد، لطفا با بخش پشتیبانی تماس بگیرید.", this.GetType(), this.ID));
                throw new Exception("----abstract entity failed! ----");
            }
            clonedEntity.Id = System.Guid.NewGuid().GetHashCode();
            return(clonedEntity);
        }