Esempio n. 1
0
        private SettingTypeDTO ToDTO(SettingTypeEntity entity)
        {
            SettingTypeDTO dto = new SettingTypeDTO();

            dto.CreateTime  = entity.CreateTime;
            dto.Id          = entity.Id;
            dto.Name        = entity.Name;
            dto.Description = entity.Description;
            dto.Sort        = entity.Sort;
            dto.IsEnabled   = entity.IsEnabled;
            return(dto);
        }
Esempio n. 2
0
        public async Task <SettingTypeDTO> GetModelAsync(long id)
        {
            using (MyDbContext dbc = new MyDbContext())
            {
                SettingTypeEntity entity = await dbc.GetAll <SettingTypeEntity>().SingleOrDefaultAsync(p => p.Id == id);

                if (entity == null)
                {
                    return(null);
                }
                return(ToDTO(entity));
            }
        }
Esempio n. 3
0
        public async Task <long> AddAsync(string name, string description, int sort)
        {
            using (MyDbContext dbc = new MyDbContext())
            {
                SettingTypeEntity entity = new SettingTypeEntity();
                entity.Name        = name;
                entity.Description = description;
                entity.Sort        = sort;
                dbc.SettingTypes.Add(entity);
                await dbc.SaveChangesAsync();

                return(entity.Id);
            }
        }
Esempio n. 4
0
        public async Task <bool> DelAsync(long id)
        {
            using (MyDbContext dbc = new MyDbContext())
            {
                SettingTypeEntity entity = await dbc.GetAll <SettingTypeEntity>().SingleOrDefaultAsync(p => p.Id == id);

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

                return(true);
            }
        }
Esempio n. 5
0
        public async Task <long> EditAsync(long id, string name, string description, int sort)
        {
            using (MyDbContext dbc = new MyDbContext())
            {
                SettingTypeEntity entity = await dbc.GetAll <SettingTypeEntity>().SingleOrDefaultAsync(p => p.Id == id);

                if (entity == null)
                {
                    return(-1);
                }
                entity.Name        = name;
                entity.Description = description;
                entity.Sort        = sort;
                await dbc.SaveChangesAsync();

                return(entity.Id);
            }
        }