Example #1
0
        private IdNameDTO ToDTO(IdNameEntity idname)
        {
            IdNameDTO dto = new IdNameDTO();

            dto.Name           = idname.Name;
            dto.TypeName       = idname.TypeName;
            dto.Id             = idname.Id;
            dto.CreateDateTime = idname.CreateDateTime;
            return(dto);
        }
Example #2
0
        private IdNameDTO ToDTO(IdNameEntity entity)
        {
            IdNameDTO dto = new IdNameDTO();

            dto.CreateDateTime = entity.CreateDateTime;
            dto.Id             = entity.Id;
            dto.Name           = entity.Name;
            dto.TypeName       = entity.TypeName;
            return(dto);
        }
Example #3
0
 public long AddNew(string typeName, string name)
 {
     using (ZSZDbContext ctx = new ZSZDbContext())
     {
         IdNameEntity idName =
             new IdNameEntity()
         {
         };
         //TODO:检查重复性
         ctx.IdNames.Add(idName);
         ctx.SaveChanges();
         return(idName.Id);
     }
 }
Example #4
0
        public long AddNew(string typeName, string name)
        {
            using (MyDbContext ctx = new MyDbContext())
            {
                IdNameEntity idName =
                    new IdNameEntity {
                    Name = name, TypeName = typeName
                };

                //todo:检查重复性
                ctx.IdNames.Add(idName);
                ctx.SaveChanges();
                return(idName.Id);
            }
        }
Example #5
0
 public long AddNew(string typeName, string name, string pngUrl)
 {
     using (MyDbContext dbc = new MyDbContext())
     {
         IdNameEntity entity = new IdNameEntity();
         var          idName = dbc.IdNames.SingleOrDefault(i => i.TypeName == typeName && i.Name == name);
         if (idName != null)
         {
             throw new ArgumentException("typeName=" + typeName + ",name=" + name + "的数据已经存在");
         }
         entity.TypeName = typeName;
         entity.Name     = name;
         entity.PngUrl   = pngUrl;
         dbc.IdNames.Add(entity);
         dbc.SaveChanges();
         return(entity.Id);
     }
 }
Example #6
0
        public long AddNew(string typeName, string name)
        {
            using (ZSZDbContext ctx = new Service.ZSZDbContext())
            {
                BaseService <IdNameEntity> bs = new BaseService <IdNameEntity>(ctx);
                var          idnames          = bs.GetAll().SingleOrDefault(i => i.TypeName == typeName);
                IdNameEntity idname           = new IdNameEntity();
                if (idnames == null)
                {
                    idname.Name     = name;
                    idname.TypeName = typeName;
                }

                ctx.IdNames.Add(idname);
                ctx.SaveChanges();
                return(idname.Id);
            }
        }
Example #7
0
        public long AddNew(string typeName, string name)
        {
            using (ZSZDbContext ctx = new ZSZDbContext())
            {
                IdNameEntity idName =
                    new IdNameEntity {
                    Name = name, TypeName = typeName
                };

                //检查重复性
                if (ctx.IdNames.Any(n => n.Name.Equals(name) && n.TypeName.Equals(typeName)))
                {
                    throw new ArgumentException("字典项已经存在:" + name);
                }

                ctx.IdNames.Add(idName);
                ctx.SaveChanges();
                return(idName.Id);
            }
        }