示例#1
0
        public async Task <List <SelectDto> > SelectDeps(int?id)
        {
            var results = new List <SelectDto>();
            //     var deps =  db.Department.Where(o=>o.Isdel!=true).Where(o => o.Pid == id || (id == null && o.Pid == 0)).Include(x => x.Children).AsAsyncEnumerable();
            //    await foreach (var x in deps)
            //     {
            //         var dto = new SelectDto()
            //         {
            //             title = x.DepName,
            //             label = x.DepName,
            //             key = x.Id,
            //             children = await SelectDeps(x.Id)
            //         };
            //         results.Add(dto);
            //     };
            var deps = await db.Department.Where(o => o.Isdel != true).Where(o => o.Pid == id || (id == null && o.Pid == 0)).Include(x => x.Children).ToListAsync();

            for (int i = 0; i < deps.Count; i++)
            {
                var dto = new SelectDto()
                {
                    title    = deps[i].DepName,
                    label    = deps[i].DepName,
                    key      = deps[i].Id,
                    children = await SelectDeps(deps[i].Id)
                };
                results.Add(dto);
            }
            ;
            return(results);
        }
示例#2
0
        public async Task <List <SelectDto> > SelectMenus(int?id)
        {
            var results = new List <SelectDto>();
            //var menus = await db.Menu.Where(o => o.Pid == id).Include(x => x.Children).ToListAsync();
            //for (int i = 0; i < menus.Count; i++)
            //{
            //    var dto = new SelectDto()
            //    {
            //        title = menus[i].Text,
            //        label = menus[i].Text,
            //        key = menus[i].Id,
            //        children = await SelectMenus(menus[i].Id)
            //    };
            //    results.Add(dto);
            //}
            var menus = db.Menu.Where(o => o.Pid == id).Include(x => x.Children).AsAsyncEnumerable();

            // forEach 只支持同步代码,c#8.0后引入了await foreach;
            await foreach (var x in menus)
            {
                var dto = new SelectDto()
                {
                    title    = x.Text,
                    label    = x.Text,
                    key      = x.Id,
                    children = await SelectMenus(x.Id)
                };
                results.Add(dto);
            }
            ;
            return(results);
        }
示例#3
0
        private List <SelectGroupDto> GetSelectGroupList(List <Operation> operations)
        {
            List <SelectGroupDto> results = new List <SelectGroupDto>();
            //regroupement par idOperationType
            List <OperationType> operationTypes = operations.Select(x => x.OperationType).Distinct().ToList();

            foreach (var operationType in operationTypes)
            {
                SelectGroupDto selectGroup = new SelectGroupDto {
                    Id = operationType.Id, Label = operationType.Label
                };

                var operationsByOperationType = operations.Where(x => x.IdOperationType == operationType.Id).ToList();
                foreach (var operation in operationsByOperationType)
                {
                    SelectDto selectDto = new SelectDto {
                        Id = operation.Id, Label = operation.Label
                    };
                    selectGroup.Selects.Add(selectDto);
                }

                results.Add(selectGroup);
            }
            return(results);
        }
示例#4
0
        public async Task <List <SelectDto> > SelectAreas(int?id)
        {
            var results = new List <SelectDto>();
            var menus   = await db.Area.Where(o => o.Pid == id).Include(x => x.Children).ToListAsync();

            foreach (var x in menus)
            {
                var dto = new SelectDto()
                {
                    title  = x.District,
                    label  = x.District,
                    key    = x.Id,
                    value  = x.Id,
                    isLeaf = true,
                };
                dto.children = await SelectAreas(x.Id);

                if (dto.children != null && dto.children.Count > 0)
                {
                    dto.isLeaf = false;
                }
                results.Add(dto);
            }
            ;
            return(results);
        }
示例#5
0
        public async Task <List <SelectDto> > SelectCompanys(int?id)
        {
            var results = new List <SelectDto>();
            //   var companys =await  db.Company.Where(o=>o.Isdel!=true).Where(o => o.Pid == id || (id == null && o.Pid == 0)).Include(x => x.Children).ToListAsync();
            //   for (int i = 0; i < companys.Count; i++)
            //   {
            //     var dto = new SelectDto()
            //     {
            //         title = companys[i].Name,
            //         label = companys[i].Name,
            //         key = companys[i].Id,
            //         children = await SelectCompanys(companys[i].Id)
            //     };
            //     results.Add(dto);
            //   }
            var companys = db.Company.Where(o => o.Isdel != true).Where(o => o.Pid == id || (id == null && o.Pid == 0)).Include(x => x.Children).AsAsyncEnumerable();

            await foreach (var x in companys)
            {
                var dto = new SelectDto()
                {
                    title    = x.Name,
                    label    = x.Name,
                    key      = x.Id,
                    children = await SelectCompanys(x.Id)
                };
                results.Add(dto);
            }
            ;
            return(results);
        }
示例#6
0
        /// <summary>
        /// 创建选择题
        /// </summary>
        /// <param name="selectDto"></param>
        /// <returns></returns>
        public async Task <SelectDto> CreateSelect(SelectDto selectDto)
        {
            // selectDto.CreateTime = TimeUtil.GetTimeStampNow();
            var selectInsert = await _selectRepository
                               .InsertNowAsync(selectDto.Adapt <TbSelect>());

            return(selectInsert.Entity.Adapt <SelectDto>());
        }
示例#7
0
 public IActionResult DynamicQuery([FromBody] SelectDto <T, TD> selectDto)
 {
     using (var uow = new UnitOfWork <TD>())
     {
         var repository = uow.GetRepository <T>();
         return(Json(repository.GetAll(selectDto.GetExpression())
                     .Include(repository.GetDbContext().GetIncludePaths(typeof(T))).ToList()));
     }
 }
 public static void addSelectToList(List <SelectDto> selectDtos, dynamic selects, int SelectId)
 {
     foreach (var select in selects)
     {
         SelectDto selectDto = new SelectDto {
             Nombre = select.Nombre, OptionId = select.Id, SelectId = SelectId
         };
         if (select.GetType().GetProperty("Subcategorias") != null)
         {
             selectDto.childOptions = new List <dynamic>(select.Subcategorias);
         }
         selectDtos.Add(selectDto);
     }
 }
示例#9
0
        static void SelectDto_Test()
        {
            string selectDtoStringValue = "{\"Filter\":[{\"PropertyName\":\"StringValue\",\"Operation\":\"IN\",\"PropertyValue\":\"Str1,Str2\"}],\"FilterCompareType\":\"AND\",\"FilterCompareTypes\":[{\"Group\":\"gp\",\"Type\":\"OR\"}],\"TakeCount\":1,\"SkipCount\":1}";

            //selectDtoStringValue = "{\"Filter\":[{\"PropertyName\":\"IntValue\",\"Operation\":\"EQ\",\"PropertyValue\":100},{\"PropertyName\":\"BoolValue\",\"Operation\":\"EQ\",\"PropertyValue\":\"false\"},{\"PropertyName\":\"BigIntValue\",\"Operation\":\"EQ\",\"PropertyValue\":\"1001\"},{\"PropertyName\":\"StringValue\",\"Operation\":\"EQ\",\"PropertyValue\":\"Str1\"},{\"PropertyName\":\"ByteValue\",\"Operation\":\"EQ\",\"PropertyValue\":254},{\"PropertyName\":\"DecimalValue\",\"Operation\":\"EQ\",\"PropertyValue\":\"12.3\"},{\"PropertyName\":\"DoubleValue\",\"Operation\":\"EQ\",\"PropertyValue\":\"17.5\"},{\"PropertyName\":\"EnumValue\",\"Operation\":\"EQ\",\"PropertyValue\":\"2\"},{\"PropertyName\":\"SmallIntValue\",\"Operation\":\"EQ\",\"PropertyValue\":\"10\"}],\"FilterCompareType\":\"AND\",\"FilterCompareTypes\":[{\"Group\":\"gp\",\"Type\":\"OR\"}]}";

            SelectDto <Search, MasterContext> selectDtoString = JsonConvert.DeserializeObject <SelectDto <Search, MasterContext> >(selectDtoStringValue);

            using (UnitOfWork <MasterContext> uow = new UnitOfWork <MasterContext>())
            {
                uow.GetRepository <Search>().Add(new Search()
                {
                    StringValue       = "Str1",
                    IntValue          = 100,
                    BigIntValue       = 1001,
                    SmallIntValue     = 10,
                    BoolValue         = false,
                    ByteValue         = 254,
                    DateTimeValue     = DateTime.Now.AddDays(-1),
                    DecimalValue      = 12.3m,
                    DoubleValue       = 17.5,
                    EnumValue         = Number.Two,
                    GuidValue         = Guid.NewGuid(),
                    GuidNullableValue = Guid.NewGuid(),
                    IntNullableValue  = null
                });

                uow.GetRepository <Search>().Add(new Search()
                {
                    StringValue       = "Str2",
                    IntValue          = 101,
                    BigIntValue       = 1002,
                    SmallIntValue     = 11,
                    BoolValue         = true,
                    ByteValue         = 255,
                    DateTimeValue     = DateTime.Now,
                    DecimalValue      = 16.3m,
                    DoubleValue       = 10.5,
                    EnumValue         = Number.One,
                    GuidValue         = Guid.NewGuid(),
                    GuidNullableValue = null,
                    IntNullableValue  = 1
                });

                uow.SaveChanges();
                //var allData = uow.GetRepository<Search>().GetAll(x => x.BoolValue == bool.Parse("false") && x.StringValue == "Str1").ToList();

                var queryResult = selectDtoString.GetQueryObject(uow).ToList();
            }
        }
示例#10
0
        /// <summary>
        /// 更新选择题
        /// </summary>
        /// <param name="selectDto"></param>
        /// <returns></returns>
        /// <exception cref="Exception"></exception>
        public async Task <SelectDto> UpdateSelect(SelectDto selectDto)
        {
            var selectEntity = await _selectRepository.FirstOrDefaultAsync(u => u.Id == selectDto.Id);

            if (selectEntity == null)
            {
                throw Oops.Oh(SelectErrorCodes.x1701);
            }

            var selectUpdate = selectDto.Adapt(selectEntity);
            await selectUpdate
            .UpdateExcludeAsync(u => u.CreateTime);

            return(selectUpdate.Adapt <SelectDto>());
        }
        private List <SelectGroupDto> GetSelectGroupList(List <OperationTypeFamily> operationTypeFamilies, EnumMovement enumMovement)
        {
            List <SelectGroupDto> results = new List <SelectGroupDto>();

            SelectGroupDto selectGroup = new SelectGroupDto {
                Id = (int)enumMovement, Label = enumMovement.ToString()
            };

            foreach (var operationTypeFamily in operationTypeFamilies)
            {
                SelectDto selectDto = new SelectDto {
                    Id = operationTypeFamily.Id, Label = operationTypeFamily.Label
                };
                selectGroup.Selects.Add(selectDto);
            }
            results.Add(selectGroup);

            return(results);
        }
示例#12
0
        public IHttpActionResult ChangeSelect(SelectDto dto)
        {
            var selected = db.SupplierOffers
                           .Where(o => o.Id == dto.OfferId)
                           .Single();

            selected.IsSelected = true;

            var sumSupplies = db.FactorySumSupplies.SingleOrDefault();

            sumSupplies.Buttons  += selected.Buttons;
            sumSupplies.Cloth    += selected.Cloth;
            sumSupplies.Stickers += selected.Stickers;
            sumSupplies.Thread   += selected.Thread;
            sumSupplies.Zipper   += selected.Zipper;

            db.SaveChanges();

            return(Ok());
        }
示例#13
0
        public PlanForTableComboFilter GetPlanTableComboFilter()
        {
            //PlanForTableComboFilter PlanForTableComboFilter = new PlanForTableComboFilter();
            var years = _planRepository.GetDistinctYears();
            List <SelectDto> comboYears = new List <SelectDto>();
            SelectDto        selected   = new SelectDto();

            foreach (var year in years)
            {
                selected = new SelectDto {
                    Id = year, Label = year.ToString()
                };
                comboYears.Add(selected);
            }

            return(new PlanForTableComboFilter
            {
                Years = new ComboSimple <SelectDto>
                {
                    List = comboYears,
                    Selected = selected
                }
            });
        }
        //public SelectDto GetUnknown(int idUserGroup)
        //{
        //    var operationTypeFamily = _operationTypeFamilyRepository.GetUnknown(idUserGroup);
        //    return _mapper.Map<SelectDto>(operationTypeFamily);
        //}

        private List <SelectDto> GetOtfLogoList()
        {
            List <SelectDto> logoList = new List <SelectDto>();
            var basePath = _hostingEnvironment.WebRootPath;
            var files    = Directory.EnumerateFiles($"{basePath}/assets/images/Otf");
            int i        = 0;

            foreach (var file in files)
            {
                string fileName = Path.GetFileName(file);
                if (fileName.Contains("_32"))
                {
                    var logo = new SelectDto
                    {
                        Id    = i,
                        Label = fileName.Replace("_32.png", string.Empty)
                    };
                    logoList.Add(logo);
                    i++;
                }
            }
            //var toto = Directory.GetFiles("/assets/images/Otf");
            return(logoList);
        }
        public async Task <IActionResult> InsertSelectOption(SelectDto selectDto)
        {
            var currentUser = HttpContext.User;

            if (currentUser.HasClaim(c => c.Type == "username"))
            {
                var     username = currentUser.Claims.FirstOrDefault(c => c.Type == "username").Value;
                Usuario user     = await _context.Usuarios.FirstOrDefaultAsync <Usuario>(u => u.Username == username);

                bool    notFound  = false;
                dynamic selectObj = null;
                switch (selectDto.SelectId)
                {
                case 1:
                    selectObj = new Actividad
                    {
                        Nombre = selectDto.Nombre
                    };
                    await _context.Actividades.AddAsync(selectObj);

                    await _context.SaveChangesAsync();

                    break;

                case 2:
                    selectObj = new Area
                    {
                        Nombre = selectDto.Nombre
                    };
                    await _context.Areas.AddAsync(selectObj);

                    await _context.SaveChangesAsync();

                    break;

                case 3:
                    selectObj = new Casualidad
                    {
                        Nombre = selectDto.Nombre
                    };
                    await _context.Casualidades.AddAsync(selectObj);

                    await _context.SaveChangesAsync();

                    break;

                case 4:
                    selectObj = new CausaBasica
                    {
                        Nombre = selectDto.Nombre
                    };
                    await _context.CausaBasicas.AddAsync(selectObj);

                    await _context.SaveChangesAsync();

                    break;

                case 5:
                    selectObj = new CausaInmediata
                    {
                        Nombre = selectDto.Nombre
                    };
                    await _context.CausaInmediatas.AddAsync(selectObj);

                    await _context.SaveChangesAsync();

                    break;

                case 6:
                    selectObj = new Clasificacion
                    {
                        Nombre = selectDto.Nombre
                    };
                    await _context.Clasificaciones.AddAsync(selectObj);

                    await _context.SaveChangesAsync();

                    break;

                case 7:
                    selectObj = new Comportamiento
                    {
                        Nombre = selectDto.Nombre
                    };
                    await _context.Comportamientos.AddAsync(selectObj);

                    await _context.SaveChangesAsync();

                    break;

                case 8:
                    selectObj = new Efecto
                    {
                        Nombre = selectDto.Nombre
                    };
                    await _context.Efectos.AddAsync(selectObj);

                    await _context.SaveChangesAsync();

                    break;

                case 9:
                    selectObj = new FactorRiesgo
                    {
                        Nombre = selectDto.Nombre
                    };
                    await _context.FactorRiesgos.AddAsync(selectObj);

                    await _context.SaveChangesAsync();

                    break;

                case 10:
                    selectObj = new Genero
                    {
                        Nombre = selectDto.Nombre
                    };
                    await _context.Generos.AddAsync(selectObj);

                    await _context.SaveChangesAsync();

                    break;

                case 11:
                    selectObj = new IndicadorRiesgo
                    {
                        Nombre = selectDto.Nombre
                    };
                    await _context.IndicadorRiesgos.AddAsync(selectObj);

                    await _context.SaveChangesAsync();

                    break;

                case 12:
                    selectObj = new Jornada
                    {
                        Nombre = selectDto.Nombre
                    };
                    await _context.Jornadas.AddAsync(selectObj);

                    await _context.SaveChangesAsync();

                    break;

                case 13:
                    selectObj = new Observado
                    {
                        Nombre = selectDto.Nombre
                    };
                    await _context.Observados.AddAsync(selectObj);

                    await _context.SaveChangesAsync();

                    break;

                case 14:
                    selectObj = new ParteCuerpo
                    {
                        Nombre = selectDto.Nombre
                    };
                    await _context.ParteCuerpos.AddAsync(selectObj);

                    await _context.SaveChangesAsync();

                    break;

                case 15:
                    selectObj = new Proceso
                    {
                        Nombre = selectDto.Nombre
                    };
                    await _context.Procesos.AddAsync(selectObj);

                    await _context.SaveChangesAsync();

                    break;

                case 16:
                    selectObj = new Riesgo
                    {
                        Nombre = selectDto.Nombre
                    };
                    await _context.Riesgos.AddAsync(selectObj);

                    await _context.SaveChangesAsync();

                    break;

                case 17:
                    selectObj = new TipoComportamiento
                    {
                        Nombre = selectDto.Nombre
                    };
                    await _context.TipoComportamientos.AddAsync(selectObj);

                    await _context.SaveChangesAsync();

                    break;

                case 18:
                    selectObj = new TipoObservado
                    {
                        Nombre = selectDto.Nombre
                    };
                    await _context.TipoObservados.AddAsync(selectObj);

                    await _context.SaveChangesAsync();

                    break;

                case 19:
                    selectObj = new Turno
                    {
                        Nombre = selectDto.Nombre
                    };
                    await _context.Turnos.AddAsync(selectObj);

                    await _context.SaveChangesAsync();

                    break;

                case 20:
                    selectObj = new Categoria
                    {
                        Nombre = selectDto.Nombre
                    };
                    await _context.Categorias.AddAsync(selectObj);

                    await _context.SaveChangesAsync();

                    break;

                case 21:
                    if (selectDto.ParentOptionId != null)
                    {
                        selectObj = new Subcategoria
                        {
                            Nombre      = selectDto.Nombre,
                            CategoriaId = selectDto.ParentOptionId ?? 0
                        };
                        await _context.Subcategorias.AddAsync(selectObj);

                        await _context.SaveChangesAsync();

                        break;
                    }
                    else
                    {
                        notFound = true;
                        break;
                    }


                default:
                    notFound = true;
                    break;
                }
                if (notFound)
                {
                    return(StatusCode(400));
                }
                Bitacora bitacora = new Bitacora
                {
                    Fecha               = DateTime.Now,
                    UsuarioId           = user.Id,
                    DescripcionBitacora = $"Creó nueva opción de formulario {selectObj.Nombre}"
                };
                await _context.Bitacora.AddAsync(bitacora);

                await _context.SaveChangesAsync();

                return(Ok(selectObj));
            }
            return(Unauthorized());
        }
        public async Task <IActionResult> UpdateSelectOption(SelectDto selectDto)
        {
            var currentUser = HttpContext.User;

            if (currentUser.HasClaim(c => c.Type == "username"))
            {
                var     username = currentUser.Claims.FirstOrDefault(c => c.Type == "username").Value;
                Usuario user     = await _context.Usuarios.FirstOrDefaultAsync <Usuario>(u => u.Username == username);

                bool    notFound  = false;
                var     selectId  = selectDto.SelectId;
                var     optionId  = selectDto.OptionId;
                var     nombre    = selectDto.Nombre;
                dynamic selectObj = null;
                switch (selectId)
                {
                case 1:
                    selectObj = await _context.Actividades.FirstOrDefaultAsync(selectDto => selectDto.Id == optionId);

                    if (selectObj != null)
                    {
                        selectObj.Nombre = nombre;
                        _context.Actividades.Update(selectObj);
                    }
                    break;

                case 2:
                    selectObj = await _context.Areas.FirstOrDefaultAsync(selectDto => selectDto.Id == optionId);

                    if (selectObj != null)
                    {
                        selectObj.Nombre = nombre;
                        _context.Areas.Update(selectObj);
                    }
                    break;

                case 3:
                    selectObj = await _context.Casualidades.FirstOrDefaultAsync(selectDto => selectDto.Id == optionId);

                    if (selectObj != null)
                    {
                        selectObj.Nombre = nombre;
                        _context.Casualidades.Update(selectObj);
                    }
                    break;

                case 4:
                    selectObj = await _context.CausaBasicas.FirstOrDefaultAsync(selectDto => selectDto.Id == optionId);

                    if (selectObj != null)
                    {
                        selectObj.Nombre = nombre;
                        _context.CausaBasicas.Update(selectObj);
                    }
                    break;

                case 5:
                    selectObj = await _context.CausaInmediatas.FirstOrDefaultAsync(selectDto => selectDto.Id == optionId);

                    if (selectObj != null)
                    {
                        selectObj.Nombre = nombre;
                        _context.CausaInmediatas.Update(selectObj);
                    }
                    break;

                case 6:
                    selectObj = await _context.Clasificaciones.FirstOrDefaultAsync(selectDto => selectDto.Id == optionId);

                    if (selectObj != null)
                    {
                        selectObj.Nombre = nombre;
                        _context.Clasificaciones.Update(selectObj);
                    }
                    break;

                case 7:
                    selectObj = await _context.Comportamientos.FirstOrDefaultAsync(selectDto => selectDto.Id == optionId);

                    if (selectObj != null)
                    {
                        selectObj.Nombre = nombre;
                        _context.Comportamientos.Update(selectObj);
                    }
                    break;

                case 8:
                    selectObj = await _context.Efectos.FirstOrDefaultAsync(selectDto => selectDto.Id == optionId);

                    if (selectObj != null)
                    {
                        selectObj.Nombre = nombre;
                        _context.Efectos.Update(selectObj);
                    }
                    break;

                case 9:
                    selectObj = await _context.FactorRiesgos.FirstOrDefaultAsync(selectDto => selectDto.Id == optionId);

                    if (selectObj != null)
                    {
                        selectObj.Nombre = nombre;
                        _context.FactorRiesgos.Update(selectObj);
                    }
                    break;

                case 10:
                    selectObj = await _context.Generos.FirstOrDefaultAsync(selectDto => selectDto.Id == optionId);

                    if (selectObj != null)
                    {
                        selectObj.Nombre = nombre;
                        _context.Generos.Update(selectObj);
                    }
                    break;

                case 11:
                    selectObj = await _context.IndicadorRiesgos.FirstOrDefaultAsync(selectDto => selectDto.Id == optionId);

                    if (selectObj != null)
                    {
                        selectObj.Nombre = nombre;
                        _context.IndicadorRiesgos.Update(selectObj);
                    }
                    break;

                case 12:
                    selectObj = await _context.Jornadas.FirstOrDefaultAsync(selectDto => selectDto.Id == optionId);

                    if (selectObj != null)
                    {
                        selectObj.Nombre = nombre;
                        _context.Jornadas.Update(selectObj);
                    }
                    break;

                case 13:
                    selectObj = await _context.Observados.FirstOrDefaultAsync(selectDto => selectDto.Id == optionId);

                    if (selectObj != null)
                    {
                        selectObj.Nombre = nombre;
                        _context.Observados.Update(selectObj);
                    }
                    break;

                case 14:
                    selectObj = await _context.ParteCuerpos.FirstOrDefaultAsync(selectDto => selectDto.Id == optionId);

                    if (selectObj != null)
                    {
                        selectObj.Nombre = nombre;
                        _context.ParteCuerpos.Update(selectObj);
                    }
                    break;

                case 15:
                    selectObj = await _context.Procesos.FirstOrDefaultAsync(selectDto => selectDto.Id == optionId);

                    if (selectObj != null)
                    {
                        selectObj.Nombre = nombre;
                        _context.Procesos.Update(selectObj);
                    }
                    break;

                case 16:
                    selectObj = await _context.Riesgos.FirstOrDefaultAsync(selectDto => selectDto.Id == optionId);

                    if (selectObj != null)
                    {
                        selectObj.Nombre = nombre;
                        _context.Riesgos.Update(selectObj);
                    }
                    break;

                case 17:
                    selectObj = await _context.TipoComportamientos.FirstOrDefaultAsync(selectDto => selectDto.Id == optionId);

                    if (selectObj != null)
                    {
                        selectObj.Nombre = nombre;
                        _context.TipoComportamientos.Update(selectObj);
                    }
                    break;

                case 18:
                    selectObj = await _context.TipoObservados.FirstOrDefaultAsync(selectDto => selectDto.Id == optionId);

                    if (selectObj != null)
                    {
                        selectObj.Nombre = nombre;
                        _context.TipoObservados.Update(selectObj);
                    }
                    break;

                case 19:
                    selectObj = await _context.Turnos.FirstOrDefaultAsync(selectDto => selectDto.Id == optionId);

                    if (selectObj != null)
                    {
                        selectObj.Nombre = nombre;
                        _context.Turnos.Update(selectObj);
                    }
                    break;

                case 20:
                    selectObj = await _context.Categorias.FirstOrDefaultAsync(selectDto => selectDto.Id == optionId);

                    if (selectObj != null)
                    {
                        selectObj.Nombre = nombre;
                        _context.Categorias.Update(selectObj);
                    }
                    break;

                case 21:
                    selectObj = await _context.Subcategorias.FirstOrDefaultAsync(selectDto => selectDto.Id == optionId);

                    if (selectObj != null)
                    {
                        selectObj.Nombre = nombre;
                        _context.Subcategorias.Update(selectObj);
                    }
                    break;


                default:
                    notFound = true;
                    break;
                }
                if (notFound)
                {
                    return(StatusCode(400));
                }
                else
                {
                    Bitacora bitacora = new Bitacora
                    {
                        Fecha               = DateTime.Now,
                        UsuarioId           = user.Id,
                        DescripcionBitacora = $"Actualizó opcion de formulario {selectObj.Nombre}"
                    };
                    await _context.Bitacora.AddAsync(bitacora);

                    await _context.SaveChangesAsync();

                    return(StatusCode(201));
                }
            }
            return(Unauthorized());
        }
示例#17
0
        //private readonly OperationTypeService _operationTypeService;
        //private readonly OperationTypeFamilyService _operationTypeFamilyService;
        //private readonly OperationService _operationService;
        //private readonly IMapper _mapper;

        //public SelectService(
        //    OperationTypeService operationTypeService,
        //    OperationTypeFamilyService operationTypeFamilyService,
        //    OperationService operationService,
        //    IMapper mapper

        //    )
        //{
        //    _operationTypeService = operationTypeService;
        //    _operationTypeFamilyService = operationTypeFamilyService;
        //    _operationService = operationService;
        //    _mapper = mapper;

        //}

        public List <SelectDto> GetSelectList(EnumSelectType enumSelectType)
        {
            List <SelectDto> Selectlist = new List <SelectDto>();

            SelectDto select = new SelectDto();

            switch (enumSelectType)
            {
            case EnumSelectType.Empty:
                //Aucun ajout de base dans la liste
                return(Selectlist);

            case EnumSelectType.Inconnu:
            case EnumSelectType.Inconnue:
                //switch(enumTableRef)
                //{
                //    case EnumTableRef.OperationType:
                //        select = _mapper.Map<SelectDto>(_operationTypeService.GetUnknown(idUserGroup));
                //        break;

                //    case EnumTableRef.OperationTypeFamily:
                //        select = _mapper.Map<SelectDto>(_operationTypeFamilyService.GetUnknown(idUserGroup));
                //        break;
                //    case EnumTableRef.Operation:
                //        select = _mapper.Map<SelectDto>(_operationService.GetUnknown(idUserGroup));
                //        break;
                //    case EnumTableRef.OperationMethod:
                //    case EnumTableRef.AccountType:
                //        select = new SelectDto { Id = 1, Label = "INCONNU" }; ;
                //        break;
                //}

                select = new SelectDto {
                    Id = 1, Label = "INCONNU"
                };
                break;

            case EnumSelectType.Tous:
                select = new SelectDto {
                    Id = 0, Label = "TOUS"
                };
                break;

            case EnumSelectType.Toutes:
                select = new SelectDto {
                    Id = 0, Label = "TOUTES"
                };
                break;

            case EnumSelectType.Aucun:
                select = new SelectDto {
                    Id = -1, Label = "AUCUN"
                };
                break;

            case EnumSelectType.Aucune:
                select = new SelectDto {
                    Id = -1, Label = "AUCUNE"
                };
                break;
            }

            Selectlist.Add(select);
            return(Selectlist);
        }