public async Task <TaskResult <ComplaintsOptionsDto> > SaveAsync(ComplaintsOptionsDto optionDto)
        {
            var option = new ComplaintsOptions
            {
                Active        = optionDto.Active,
                CreatedAt     = optionDto.CreatedAt,
                Id            = optionDto.Id,
                ProductsId    = optionDto.ProductsId,
                Name          = optionDto.Name,
                UpdatedAt     = optionDto.UpdatedAt,
                DepartmentsId = optionDto.DepartmentsId
            };
            var result = new TaskResult <ComplaintsOptionsDto>();

            try
            {
                _context.ComplaintsOptions.Add(option);
                await _context.SaveChangesAsync();

                result.Message = $"Se agregó la opción {optionDto.Name}";
            }
            catch (Exception e)
            {
                result.Success = false;
                result.Message = $"Error al intentar agregar al Producto: {e.Message}";
            }
            return(result);
        }
        public async Task <TaskResult <ComplaintsOptionsDto> > UpdateAsync(ComplaintsOptionsDto optionDto)
        {
            var option = new ComplaintsOptions
            {
                Active        = optionDto.Active,
                CreatedAt     = optionDto.CreatedAt,
                Id            = optionDto.Id,
                ProductsId    = optionDto.ProductsId,
                Name          = optionDto.Name,
                UpdatedAt     = optionDto.UpdatedAt,
                DepartmentsId = optionDto.DepartmentsId
            };
            var result = new TaskResult <ComplaintsOptionsDto>();

            try
            {
                _context.ComplaintsOptions.Add(option);
                _context.Entry(option).State = System.Data.Entity.EntityState.Modified;
                await _context.SaveChangesAsync();

                result.Data    = optionDto;
                result.Message = "El registro fue actualizado correctamente";
            }
            catch (Exception e)
            {
                result.Success = false;
                result.Message = $"Error al intentar actualizar información del producto: {e.Message}";
            }
            return(result);
        }
        public async Task <ActionResult> Create(ComplaintsOptionsDto Data)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }
            var products = await _productsRepository.GetAllAsync();

            ViewBag.Products = products.Data.Select(e => new SelectListItem {
                Value = e.Id.ToString(), Text = e.Name
            }).ToList();
            var departments = await _departmentsRepository.GetAllAsync();

            ViewBag.Departments = departments.Data.Select(e => new SelectListItem {
                Value = e.Id.ToString(), Text = e.Name
            }).ToList();
            var newModel = await _complaintsOptionsRepository.SaveAsync(Data);

            return(View(newModel));
        }