public IActionResult Edit(EditComplaintViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                var complaint = _context.Complaints
                                .Include(c => c.Client)
                                .SingleOrDefault(c => c.ID == viewModel.ComplaintID);
                complaint.ComplaintStatusID = viewModel.StatusID;

                SendNotification(complaint.Client.Email, viewModel.StatusID);

                _context.SaveChanges();

                return(RedirectToAction(nameof(View), new { id = complaint.ClientProfileID }));
            }

            return(NotFound());
        }
Beispiel #2
0
        public EditComplaintViewModel EditComplaint(Int32 complaintID)
        {
            EditComplaintViewModel result = new EditComplaintViewModel
            {
                _complaint                = this.FindById(complaintID),
                _nameOfComplainant        = this.nocp.FindById(complaintID),
                _patient                  = this.patient.FindById(complaintID),
                _complaint_type_list      = this.GetComplaintTypeAssistance(complaintID, "C"),
                _complaintAssistance      = this.GetComplaintTypeAssistance(complaintID, "A"),
                date_informed_the_hf      = db._complaintsDates.Where(p => p.complaintID == complaintID && p.member == "date_informed_the_hf").ToList().Select(p => p.Date).ToList(),
                date_hf_submitted_reply   = db._complaintsDates.Where(p => p.complaintID == complaintID && p.member == "date_hf_submitted_reply").ToList().Select(p => p.Date).ToList(),
                date_release_to_records   = db._complaintsDates.Where(p => p.complaintID == complaintID && p.member == "date_release_to_records").ToList().Select(p => p.Date).ToList(),
                date_final_resolution     = db._complaintsDates.Where(p => p.complaintID == complaintID && p.member == "date_final_resolution").ToList().Select(p => p.Date).ToList(),
                _complaintActionDates     = db.complaintActionDates.Where(p => p.complaintID == complaintID),
                _createComplaintViewModel = this.getCreateComplaintViewModel(),
                _remarks                  = this.GetComplaintRemarks(complaintID)
            };

            return(result);
        }
        public IActionResult Edit(int id)
        {
            var complaint = _context.Complaints
                            .Include(c => c.Status)
                            .SingleOrDefault(c => c.ID == id);

            if (complaint == null)
            {
                return(NotFound());
            }

            EditComplaintViewModel viewModel =
                new EditComplaintViewModel(_context.ComplaintStatuses.ToList());

            viewModel.ComplaintID = complaint.ID;
            viewModel.StatusID    = complaint.ComplaintStatusID;
            viewModel.ComplaintNo = complaint.ComplaintNo;

            return(View(viewModel));
        }
Beispiel #4
0
        public async Task <IActionResult> Edit(int id, EditComplaintViewModel model)
        {
            if (id != model.Id)
            {
                return(NotFound());
            }

            var currentUser = await GetCurrentUserAsync();

            if (currentUser == null)
            {
                throw new Exception("Current user not found");
            }

            string msg;

            if (!ModelState.IsValid)
            {
                msg = string.Format("The {0} was not updated. Please fix the errors shown below.", objectDisplayName);
                ViewData["AlertMessage"] = new AlertViewModel(msg, AlertStatus.Error, "Error");

                // Populate the select lists before returning the model
                model.SelectLists = await _dal.GetCommonSelectListsAsync(currentUser.OfficeId);

                return(View(model));
            }

            var complaint = await _context.Complaints
                            .Where(e => e.Id == id)
                            .SingleOrDefaultAsync();

            if (complaint == null)
            {
                return(NotFound());
            }

            // Check permissions
            if (complaint.Deleted)
            {
                msg = "This Complaint has been deleted and cannot be edited.";
                TempData.SaveAlertForSession(msg, AlertStatus.Warning, "Access Denied");
                return(RedirectToAction("Details", new { id }));
            }
            if (currentUser.Id != complaint.CurrentOwnerId &&
                !(User.IsInRole(CtsRole.Manager.ToString()) && currentUser.OfficeId == complaint.CurrentOfficeId) &&
                !(User.IsInRole(CtsRole.DivisionManager.ToString())) &&
                !(complaint.EnteredById == currentUser.Id && complaint.DateEntered.AddHours(1) > DateTime.Now))
            {
                msg = string.Format("You do not have permission to edit this Complaint.", objectDisplayName);
                TempData.SaveAlertForSession(msg, AlertStatus.Warning, "Access Denied");
                return(RedirectToAction("Details", new { id }));
            }
            if (currentUser != null &&
                (currentUser.Id == complaint.CurrentOwnerId) &&
                (complaint.DateCurrentOwnerAccepted == null))
            {
                msg = string.Format("You must accept this Complaint before you can edit it.", objectDisplayName);
                TempData.SaveAlertForSession(msg, AlertStatus.Warning, "Access Denied");
                return(RedirectToAction("Details", new { id }));
            }
            if (complaint.ComplaintClosed)
            {
                msg = "This Complaint has been closed and cannot be edited unless it is reopened.";
                TempData.SaveAlertForSession(msg, AlertStatus.Warning, "Access Denied");
                return(RedirectToAction("Details", new { id }));
            }

            // Update complaint properties
            complaint.DateReceived = model.DateReceivedDate.Value.Date;
            if (model.DateReceivedTime.HasValue)
            {
                complaint.DateReceived = complaint.DateReceived.Add(model.DateReceivedTime.Value.TimeOfDay);
            }
            complaint.ReceivedById               = model.ReceivedById;
            complaint.CallerName                 = model.CallerName;
            complaint.CallerRepresents           = model.CallerRepresents;
            complaint.CallerStreet               = model.CallerStreet;
            complaint.CallerStreet2              = model.CallerStreet2;
            complaint.CallerCity                 = model.CallerCity;
            complaint.CallerStateId              = model.CallerStateId;
            complaint.CallerPostalCode           = model.CallerPostalCode;
            complaint.CallerPhoneNumber          = model.CallerPhoneNumber;
            complaint.CallerPhoneType            = model.CallerPhoneType;
            complaint.CallerSecondaryPhoneNumber = model.CallerSecondaryPhoneNumber;
            complaint.CallerSecondaryPhoneType   = model.CallerSecondaryPhoneType;
            complaint.CallerTertiaryPhoneNumber  = model.CallerTertiaryPhoneNumber;
            complaint.CallerTertiaryPhoneType    = model.CallerTertiaryPhoneType;
            complaint.CallerEmail                = model.CallerEmail;
            complaint.ComplaintNature            = model.ComplaintNature;
            complaint.ComplaintLocation          = model.ComplaintLocation;
            complaint.ComplaintDirections        = model.ComplaintDirections;
            complaint.ComplaintCity              = model.ComplaintCity;
            complaint.ComplaintCountyId          = model.ComplaintCountyId;
            complaint.PrimaryConcernId           = model.PrimaryConcernId;
            complaint.SecondaryConcernId         = model.SecondaryConcernId;
            complaint.SourceFacilityId           = model.SourceFacilityId;
            complaint.SourceContactName          = model.SourceContactName;
            complaint.SourceFacilityName         = model.SourceFacilityName;
            complaint.SourceStreet               = model.SourceStreet;
            complaint.SourceStreet2              = model.SourceStreet2;
            complaint.SourceCity                 = model.SourceCity;
            complaint.SourceStateId              = model.SourceStateId;
            complaint.SourcePostalCode           = model.SourcePostalCode;
            complaint.SourcePhoneNumber          = model.SourcePhoneNumber;
            complaint.SourcePhoneType            = model.SourcePhoneType;
            complaint.SourceSecondaryPhoneNumber = model.SourceSecondaryPhoneNumber;
            complaint.SourceSecondaryPhoneType   = model.SourceSecondaryPhoneType;
            complaint.SourceTertiaryPhoneNumber  = model.SourceTertiaryPhoneNumber;
            complaint.SourceTertiaryPhoneType    = model.SourceTertiaryPhoneType;
            complaint.SourceEmail                = model.SourceEmail;

            try
            {
                _context.Update(complaint);
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!(await _dal.ComplaintExistsAsync(model.Id)))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            msg = string.Format("The {0} was updated.", objectDisplayName);
            TempData.SaveAlertForSession(msg, AlertStatus.Success, "Success");

            return(RedirectToAction("Details", new { id }));
        }