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 <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); }