コード例 #1
0
ファイル: Mapper.cs プロジェクト: akagrand1k/CityLife
 public static ApplicationSysReferenceViewModel ToViewModel(ApplicationSysReferences entity)
 {
     return(new ApplicationSysReferenceViewModel
     {
         Key = entity.Key,
         Value = entity.Value,
         IsDelete = entity.IsDelete,
         IsActive = entity.IsActive,
     });
 }
コード例 #2
0
        public ApplicationSysReferences GetSysRefById(int id)
        {
            ApplicationSysReferences entity = null;

            if (id > 0)// -1
            {
                var ctx = unitOfWork.CityLifeDbContext;
                entity = ctx
                         .Set <ApplicationSysReferences>()
                         .FirstOrDefault(x => x.Id == id);
                return(entity);
            }

            return(entity);
        }
コード例 #3
0
        public void Edit(ApplicationSysReferences entity)
        {
            if (entity != null)
            {
                var ctx = unitOfWork.CityLifeDbContext;

                var editEntity = ctx
                                 .Set <ApplicationSysReferences>()
                                 .FirstOrDefault(x => x.Key == entity.Key);

                editEntity.Value = entity.Value;

                ctx.SaveChanges();
            }
        }
コード例 #4
0
        public void CreateSysByKey(string key, string value)
        {
            var entity = new ApplicationSysReferences();
            List <ApplicationSysReferences> allReferences = new List <ApplicationSysReferences>();

            var ctx = unitOfWork.CityLifeDbContext;

            if (!string.IsNullOrEmpty(key) && !string.IsNullOrEmpty(value))
            {
                var result = ctx
                             .Set <ApplicationSysReferences>()
                             .FirstOrDefault(x => x.Key == key);

                if (result == null)
                {
                    entity.Key   = key;
                    entity.Value = value;
                    ctx.Set <ApplicationSysReferences>().Add(entity);
                    ctx.SaveChanges();
                }
            }
        }