public async Task <TaskResult <ComplaintsDto> > UpdateStatusAsync(int statusId, int complaintsId) { var result = new TaskResult <ComplaintsDto>(); try { var complaints = await _context.Complaints.Include(e => e.Status).Where(e => e.Id == complaintsId && e.Active).FirstOrDefaultAsync(); var status = await _statusRepository.GetAsync(statusId); complaints.StatusId = statusId; if (status.Data.Name.ToUpper() == StatusName.CLOSED) { complaints.CompletedAt = DateTime.Now; complaints.UpdatedAt = DateTime.Now; } await _context.SaveChangesAsync(); result.Data = AutoMapper.Mapper.Map <ComplaintsDto>(complaints); result.Message = "El registro fue actualizado correctamente"; } catch (Exception e) { result.Success = false; result.Message = $"Error al intentar actualizar información de la queja: {e.Message}"; } return(result); //var complaintDto = AutoMapper.Mapper.Map<ComplaintsDto>(complaint); //var complaintUpdated = await this.UpdateAsync(complaintDto); }
public async Task <ActionResult> UpdateStatus(ComplaintsViewModel model) { var isUpdated = await _complaintsRepository.UpdateStatusAsync(model.Complaint.Data.StatusId, model.Complaint.Data.Id); var status = await _statusRepository.GetAsync(model.Complaint.Data.StatusId); if (isUpdated.Success) { var binnacle = new BinnacleDto { StatusId = model.Complaint.Data.StatusId, Comment = model.Binnacle?.Comment ?? $"SE HA CAMBIADO EL ESTADO DEL TICKET A: {status.Data.Name.ToUpper()}", ComplaintsId = model.Complaint.Data.Id, CreatedAt = DateTime.Now, ApplicationUserId = User.Identity.GetUserId() }; var addBinnacle = await _binnaclesRepository.SaveAsync(binnacle); } return(RedirectToAction("Details", new { id = model.Complaint.Data.Id })); }
public async Task <StatusModel> GetStatusAsync(int id) { return(mapper.Map <StatusModel>(await statusRepository.GetAsync(id))); }
public IEnumerable <Status> GetAll() { var tes = GeneratedCodeContribution.GetCode(); return(_statusRepository.GetAsync().Result); }
public async Task <ActionResult> Details(int id) { var model = await _statusRepository.GetAsync(id); return(View(model)); }