Beispiel #1
0
        private IdNameDTO ToDTO(IdNameEntity i)
        {
            IdNameDTO idDto = new IdNameDTO();

            idDto.Name           = i.Name;
            idDto.TypeName       = i.TypeName;
            idDto.Id             = i.Id;
            idDto.CreateDateTime = i.CreateDateTime;
            return(idDto);
        }
Beispiel #2
0
 public IdNameDTO Entity2DTO(IdNameEntity a)
 {
     return(new IdNameDTO()
     {
         Id = a.Id,
         CreateDateTime = a.CreateDateTime,
         Name = a.Name,
         TypeName = a.TypeName
     });
 }
        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);
        }
Beispiel #4
0
            public override bool Equals(object obj)
            {
                if (!(obj is IdNameEntity))
                {
                    return(false);
                }

                IdNameEntity state = (IdNameEntity)obj;

                return(obj != null && this.Id == state.Id && this.Name == state.Name);
            }
Beispiel #5
0
 public long AddNew(string typeName, string name, string imgUrl)
 {
     using (MyDbContext dbc = new MyDbContext())
     {
         IdNameEntity idName = new IdNameEntity();
         idName.TypeName = typeName;
         idName.Name     = name;
         idName.ImgUrl   = imgUrl;
         dbc.IdNames.Add(idName);
         dbc.SaveChanges();
         return(idName.Id);
     }
 }
Beispiel #6
0
        public long AddNew(string typeName, string name)
        {
            IdNameEntity idName = new IdNameEntity();

            idName.Name     = name;
            idName.TypeName = typeName;
            using (ZSZDbContext ctx = new ZSZDbContext())
            {
                ctx.IdNames.Add(idName);
                ctx.SaveChanges();
                return(idName.Id);
            }
        }
Beispiel #7
0
 public long AddNew(string typeName, string name)
 {
     using (RhDbContext ctx = new RhDbContext())
     {
         IdNameEntity idName = new IdNameEntity()
         {
             Name     = name,
             TypeName = typeName
         };
         //TODO:检查重复的情况
         ctx.IdNames.Add(idName);
         ctx.SaveChanges();
         return(idName.Id);
     }
 }
        public long AddNew(string typeName, string name)
        {
            using (PalmRentDbContext ctx = new PalmRentDbContext())
            {
                IdNameEntity idName =
                    new IdNameEntity {
                    Name = name, TypeName = typeName
                };

                //todo:检查重复性
                ctx.IdNames.Add(idName);
                ctx.SaveChanges();
                return(idName.Id);
            }
        }
Beispiel #9
0
        public async Task <bool> DelByNameAsync(string name)
        {
            using (MyDbContext dbc = new MyDbContext())
            {
                IdNameEntity idName = await dbc.GetAll <IdNameEntity>().SingleOrDefaultAsync(i => i.Name == name);

                if (idName == null)
                {
                    return(false);
                }
                idName.IsDeleted = true;
                await dbc.SaveChangesAsync();

                return(true);
            }
        }
Beispiel #10
0
 public SampleMixedEntity()
 {
     this.PIntValue     = 0;
     this.PDoubleValue  = 0.0;
     this.PBoolValue    = false;
     this.PStringValue  = "";
     this.PColorValue   = Color.black;
     this.PVector3Value = Vector3.zero;
     this.PStringArray  = new string[] { "one", "two", "three" };
     this.PListValue    = new List <string>()
     {
         "one", "two", "three"
     };
     this.PDictionaryValue = new Dictionary <string, int>()
     {
         { "one", 1 }, { "two", 2 }
     };
     this.PIdNameState = new IdNameEntity();
 }
Beispiel #11
0
            public SamplePropertyEntity()
            {
                this.IntValue    = 0;
                this.DoubleValue = 0.0;
                this.BoolValue   = false;

                this.StringValue  = "";
                this.ColorValue   = Color.black;
                this.Vector3Value = Vector3.zero;

                this.StringArray = new string[] { "one", "two", "three" };
                this.ListValue   = new List <string>()
                {
                    "one", "two", "three"
                };
                this.DictionaryValue = new Dictionary <string, int>()
                {
                    { "one", 1 }, { "two", 2 }
                };
                this.IdNameState = new IdNameEntity();
            }
Beispiel #12
0
        public long AddNew(IdNameDto model)
        {
            IdNameEntity idNameEntity = model.EntityMap();

            idNameEntity.CreateDateTime = DateTime.Now;
            using (YersDbContext ctx = new YersDbContext())
            {
                BaseService <IdNameEntity> bs
                    = new BaseService <IdNameEntity>(ctx);

                if (bs.GetAll().Any(m => m.TypeName == idNameEntity.TypeName && m.Name == idNameEntity.Name))
                {
                    throw new ArgumentException("该数据已存在,请检查");
                }

                ctx.IdNames.Add(idNameEntity);

                ctx.SaveChanges();

                return(idNameEntity.Id);
            }
        }
 public long AddIdName(string typeName, string name)
 {
     using (WarmHomeContext db = new WarmHomeContext())
     {
         BaseService <IdNameEntity> serives = new BaseService <IdNameEntity>(db);
         bool esixts = serives.GetAll().Any(e => e.TypeName == typeName && e.Name == name);
         if (esixts)
         {
             throw new ArgumentException("此数据已存在");
         }
         else
         {
             IdNameEntity entity = new IdNameEntity()
             {
                 Name     = name,
                 TypeName = typeName
             };
             db.IdNames.Add(entity);
             db.SaveChanges();
             return(entity.Id);
         }
     }
 }
Beispiel #14
0
 public static IdNameDto EntityMap(this IdNameEntity model)
 {
     return(Mapper.Map <IdNameDto>(model));
 }