public void Create(ComplaintModel model, string username)
 {
     try
     {
         _unitOfWork.BeginTransaction();
         var complaint = new Complaint
         {
             Id          = Guid.NewGuid().ToString(),
             Category    = (int)model.Category,
             Description = model.Description,
             Summary     = model.Summary,
             DateCreated = DateTime.UtcNow,
             Status      = (int)ComplaintStatus.Created,
             Type        = (int)model.Type,
             ComplainBy  = model.ComplainBy
         };
         _repository.Insert(complaint);
         _unitOfWork.Commit();
     }
     catch (Exception e)
     {
         _unitOfWork.Rollback();
         throw e;
     }
 }
        private void OnComplaintInsert()
        {
            //SelectedDrinkType = null;
            if (complaintContent != null)
            {
                LoadingShow        = true;
                LoadingShowOpacity = 1;
                try
                {
                    ComplaintModel comp = new ComplaintModel
                    {
                        Active           = 1,
                        ComplaintContent = ComplaintContent,
                        ComplaintTypeID  = ComplaintTypeID,
                    };


                    NotifySuccessMessageShow = true;
                    //System.Windows.Threading.Dispatcher.CurrentDispatcher.BeginInvoke(new Action(() => { RaisePropertyChanged("SelectedDrinkType"); }), null);
                    Mediator.NotifyColleagues("OrderItemAddedComplaints", comp);
                }
                catch (Exception ex)
                {
                    NotifyFailureMessageShow = true;
                    Mediator.NotifyColleagues(MessageConstants.NotifyMessengerBroker.Value, MessageConstants.FailureToken.Value);
                }
            }
            else
            {
                NotifyFailureMessageShow = true;
                Mediator.NotifyColleagues(MessageConstants.NotifyMessengerBroker.Value, MessageConstants.FailureToken);
            }
        }
        public void OnComplaintAdded(object arg)
        {
            ComplaintModel comp             = (ComplaintModel)arg;
            bool           successControler = false;

            if (comp != null)
            {
                try
                {
                    complaintsList.Add(comp);
                    successControler = true;
                    base.RaisePropertyChanged("ComplaintsList");
                    //throw new Exception("test exception");
                }
                catch (Exception ex)
                {
                    successControler = false;
                }
            }
            else
            {
                successControler = false;
            }

            if (successControler)
            {
                Mediator.NotifyColleagues(MessageConstants.NotifyMessengerBroker.Value, MessageConstants.SuccessToken);
            }
            else
            {
                Mediator.NotifyColleagues(MessageConstants.NotifyMessengerBroker.Value, MessageConstants.FailureToken);
            }
        }
Example #4
0
        public JsonResult Complain(ComplaintModel model)
        {
            var    twitterHandle      = TwitterLookup.TwitterHandles.FirstOrDefault(tweet => tweet.Key == model.Operator).Value;
            var    delayedOrCancelled = model.Expected == "Cancelled" ? "CANCELLED" : "DELAYED";
            string message            = string.Format(
                "#complaint received for {0}. The {1} from {2} to {3} is {4}. SORT IT OUT! @transportgovuk",
                twitterHandle,
                model.Due,
                model.OriginalSearch,
                model.Destination,
                delayedOrCancelled
                );

            while (message.Length < 140)
            {
                int    availableSpace  = 140 - message.Length;
                string selectedHashtag = hashtags.Where(s => s.Length <= availableSpace && !message.Contains(s)).FirstOrDefault();

                if (string.IsNullOrWhiteSpace(selectedHashtag))
                {
                    break;
                }

                message += selectedHashtag;
            }

            this.twitterService.Tweet(message);
            return(this.Json(model.Operator));
        }
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var settings   = DependencyService.Get <IAppSettings>();
            var Controller = EnumExtensionMethods.GetEnumDescription(UserRole.Controller);
            var Admin      = EnumExtensionMethods.GetEnumDescription(UserRole.Admin);
            var SiteAdmin  = EnumExtensionMethods.GetEnumDescription(UserRole.SiteAdmin);


            ComplaintModel complaint = (ComplaintModel)value;

            if (complaint.ComplainStatus == (int)ComplaintStatusEnum.Pending || complaint.ComplainStatus == (int)ComplaintStatusEnum.Rejected)
            {
                if ((settings.UserRole.Equals(Controller) || settings.UserRole.Equals(Admin) || settings.UserRole.Equals(SiteAdmin)) && complaint.CreatedBy.Equals(settings.UserId))
                {
                    return(true);
                }
                else
                {
                    if (!settings.UserRole.Equals(Controller) || settings.UserRole.Equals(Admin) || settings.UserRole.Equals(SiteAdmin))
                    {
                        return(true);
                    }
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
        public async Task <IActionResult> Create(ComplaintModel model)
        {
            if (ModelState.IsValid)
            {
                var request = await _dbContext.Requests.GetSimpleRequestById(model.RequestId);

                if ((await _authorizationService.AuthorizeAsync(User, request, Policies.CreateComplaint)).Succeeded)
                {
                    try
                    {
                        await _complaintService.Create(request, User.GetUserId(), User.TryGetImpersonatorId(), model.Message, model.ComplaintType.Value);

                        await _dbContext.SaveChangesAsync();
                    }
                    catch (InvalidOperationException ex)
                    {
                        _logger.LogError("Wrong status or complaint exists when trying to Create complaint. Status: {request.Status}, RequestId {request.RequestId}", request.Status, request.RequestId);
                        return(RedirectToAction("Index", "Home", new { errormessage = ex.Message }));
                    }
                    return(RedirectToAction("View", "Order", new { id = request.OrderId, tab = "complaint" }));
                }
                return(Forbid());
            }
            return(View(nameof(Create), model));
        }
        public ActionResult <ComplaintModel> Post([FromBody] ComplaintModel complaintItem)
        {
            _logger.LogInformation("Request to log new Complaint received");

            _db.CreateComplaint(complaintItem);

            _logger.LogInformation("Complaint successfully logged with ID {0}", complaintItem.ID);
            return(complaintItem);
        }
Example #8
0
 public async Task SaveComplaint(ComplaintModel model)
 {
     try
     {
         _complaintRepo.InsertOrReplaceWithChildren(model);
     }
     catch (Exception ex)
     {
     }
 }
Example #9
0
 public void DeleteComplaint(int id)
 {
     //unitOfWork.StartTransaction();
     ComplaintRepository repo = new ComplaintRepository(unitOfWork);
     ComplaintModel complaintModel = new ComplaintModel();
     Complaint complaint = new Complaint();
     complaint = repo.GetAll().Where(x => x.ComplaintId == id).SingleOrDefault();
     repo.Delete(x => x.ComplaintId == complaint.ComplaintId);
     //unitOfWork.Commit();
 }
Example #10
0
        public ActionResult FileComplaint()
        {
            ComplaintModel model = new ComplaintModel();

            model.IncidentDate    = DateTime.Today;
            model.ComplaintStatus = ComplaintStatus.Open.ToString();
            ViewBag.Message       = "Create Complaint";

            return(View(model));
        }
Example #11
0
 public ComplaintModel GetComplaintByComplaintId(int complaintId)
 {
     //unitOfWork.StartTransaction();
     ComplaintRepository repo = new ComplaintRepository(unitOfWork);
     ComplaintModel complaintModel = new ComplaintModel();
     Complaint complaint = new Complaint();
     complaint = repo.GetAll().Where(x => x.ComplaintId == complaintId).FirstOrDefault();
     //unitOfWork.Commit();
     AutoMapper.Mapper.Map(complaint, complaintModel);
     return complaintModel;
 }
 public IActionResult Save([FromBody] ComplaintModel model)
 {
     try
     {
         _complaintService.Save(model);
         return(Ok());
     }
     catch (Exception ex)
     {
         _logger.LogError("error occrured: {0}", ex.ToString());
         return(BadRequest(new { message = "Server Exception" }));
     }
 }
Example #13
0
 public void DeleteComplaintbyEmployeeId(string id)
 {
     //unitOfWork.StartTransaction();
     ComplaintRepository repo = new ComplaintRepository(unitOfWork);
     ComplaintModel complaintModel = new ComplaintModel();
        List<Complaint> complaints = new List<Complaint>();
     complaints = repo.GetAll().Where(x => x.EmployeeId == id).ToList();
     complaints.ForEach(x =>
     {
         repo.Delete(y => y.ComplaintId == x.ComplaintId);
     });
     //unitOfWork.Commit();
 }
Example #14
0
 public ActionResult AddComplaint(ComplaintModel ObjComp)
 {
     try
     {
         ComplaintRepo Obj = new ComplaintRepo();
         ViewBag.ComplaintId = "Successfully, Your Id: " + Obj.AddComplaint(ObjComp);
     }
     catch (Exception)
     {
         ViewBag.ComplaintId = "error, please check details";
     }
     return(View());
 }
Example #15
0
        public async Task <bool> SaveOnServer(ComplaintModel complaintModel)
        {
            try
            {
                List <KeyValuePair <string, string> > ListOfParameters = new List <KeyValuePair <string, string> >();
                ListOfParameters.Add(new KeyValuePair <string, string>("ShopName", complaintModel.ShopName));
                ListOfParameters.Add(new KeyValuePair <string, string>("Id", Convert.ToString(complaintModel.ExternalId)));
                ListOfParameters.Add(new KeyValuePair <string, string>("ShopAddress", complaintModel.ShopAddress));
                ListOfParameters.Add(new KeyValuePair <string, string>("DateOfInspection", complaintModel.DateOfInspection?.ToString("dd-MMM-yyyy")));
                ListOfParameters.Add(new KeyValuePair <string, string>("Comments", complaintModel.Comments ?? " "));
                ListOfParameters.Add(new KeyValuePair <string, string>("Violations", complaintModel.Violations ?? " "));
                ListOfParameters.Add(new KeyValuePair <string, string>("GpsLocations", complaintModel.GpsLocations ?? " "));
                ListOfParameters.Add(new KeyValuePair <string, string>("UserId", _settings.UserId ?? " "));
                ListOfParameters.Add(new KeyValuePair <string, string>("Cityid", Convert.ToString(_settings.UserCityId) ?? "0"));
                ListOfParameters.Add(new KeyValuePair <string, string>("SpeciesId", Convert.ToString(complaintModel.SpeciesId) ?? "0"));
                ListOfParameters.Add(new KeyValuePair <string, string>("ComplainStatus", Convert.ToString(complaintModel.ComplainStatus)));
                ListOfParameters.Add(new KeyValuePair <string, string>("GroupName", complaintModel.GroupName ?? " "));
                ListOfParameters.Add(new KeyValuePair <string, string>("IsDelete", "false"));
                ListOfParameters.Add(new KeyValuePair <string, string>("IsActive", "true"));
                ListOfParameters.Add(new KeyValuePair <string, string>("LowIds", complaintModel.LowsId));
                ListOfParameters.Add(new KeyValuePair <string, string>("IsRejecet", Convert.ToString(complaintModel.IsRejecet ?? false)));
                ListOfParameters.Add(new KeyValuePair <string, string>("CommentForRejection", Convert.ToString(complaintModel.CommentForRejection ?? " ")));
                ListOfParameters.Add(new KeyValuePair <string, string>("RegistrationDate", complaintModel.RegistrationDate?.ToString("dd-MMMM-yyyy hh:mm:ss") ?? DateTime.Now.ToString("dd-MMMM-yyyy hh:mm:ss")));
                ListOfParameters.Add(new KeyValuePair <string, string>("IsRegister", Convert.ToString(complaintModel.IsRegister ?? false)));
                ListOfParameters.Add(new KeyValuePair <string, string>("IsEmailSend", Convert.ToString(complaintModel.IsEmailSend ?? false)));
                List <byte[]> fileBlob = new List <byte[]>();
                if (!string.IsNullOrEmpty(complaintModel.Files))
                {
                    List <string> SplitFilePaths = new List <string>();

                    SplitFilePaths = complaintModel.Files.Split(',')?.ToList();
                    if (SplitFilePaths.AnyExtended())
                    {
                        foreach (var item in SplitFilePaths)
                        {
                            var ByteArray = await FileExtensions.LoadFileBytesAsync(item);

                            fileBlob.Add(ByteArray);
                        }
                    }
                }

                var responce = await restapiHelper.SaveComplaint(EndPoint.Complaint.SaveComplaints, ListOfParameters, fileBlob);

                return(responce);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
        public void Save(ComplaintModel _complaint)
        {
            Complaint complaint = new Complaint()
            {
                CreatedBy   = _complaint.UserId,
                CreatedDate = DateTime.Now,
                Description = _complaint.Description,
                Department  = _complaint.Department,
                Subject     = _complaint.Subject
            };

            _db.Complaint.Add(complaint);
            _db.SaveChanges();
        }
Example #17
0
        public string AddComplaint(ComplaintModel Obj)
        {
            DynamicParameters ObjParm = new DynamicParameters();

            ObjParm.Add("@ComplaintType", Obj.ComplaintType);
            ObjParm.Add("@ComplaintDesc", Obj.ComplaintDesc);
            ObjParm.Add("@ComplaintId", dbType: System.Data.DbType.String, direction: System.Data.ParameterDirection.Output, size: 951652);
            con.Open();
            con.Execute("AddComplaint", ObjParm, commandType: CommandType.StoredProcedure);
            var ComplaintId = ObjParm.Get <string>("@ComplaintId");

            con.Close();
            return(ComplaintId);
        }
Example #18
0
        //    public ActionResult ViewComplaints()
        //{
        //    int preview_max = 15;
        //    List<DataLibrary.Models.ComplaintModel> data = new List<DataLibrary.Models.ComplaintModel>();
        //    if (Session["TenantID"] != null)
        //    {
        //        data = LoadComplaintsByUserId((int)Session["TenantID"]);
        //    }
        //    else
        //    {
        //        data = LoadComplaintsByPropertyManager((int)Session["PropertyID"]);
        //    }

        //    List<ComplaintModel> complaints = new List<ComplaintModel>();

        //    foreach (var row in data)
        //    {
        //        string preview = row.Details.Substring(0, Math.Min(preview_max, row.Details.Length));
        //        if (row.Details.Length > preview_max)
        //        {
        //            preview += "...";
        //        }

        //        complaints.Add(new ComplaintModel
        //        {
        //            Id = row.Id,
        //            ComplaintStatus = Enum.GetName(typeof(ComplaintStatus), row.ComplaintStatusId),
        //            ComplaintType = Enum.GetName(typeof(ComplaintType), row.ComplaintTypeId),
        //            Description = preview,
        //            IncidentDate = row.IncidentDate,
        //        });
        //    }

        //    return View(complaints);
        //}

        //public ActionResult ViewAllComplaints()
        //{
        //    int preview_max = 15;
        //    var data = LoadComplaints();
        //    List<ComplaintModel> complaints = new List<ComplaintModel>();

        //    foreach (var row in data)
        //    {
        //        string preview = row.Details.Substring(0, Math.Min(preview_max, row.Details.Length));
        //        if (row.Details.Length > preview_max)
        //        {
        //            preview += "...";
        //        }

        //        complaints.Add(new ComplaintModel
        //        {
        //            Id = row.Id,
        //            ComplaintStatus = Enum.GetName(typeof(ComplaintStatus), row.ComplaintStatusId),
        //            ComplaintType = Enum.GetName(typeof(ComplaintType), row.ComplaintTypeId),
        //            Description = preview,
        //            IncidentDate = row.IncidentDate,
        //        });
        //    }

        //    return View(complaints);
        //}

        public ActionResult ComplaintDetails(int id)
        {
            var            data      = LoadComplaint(id).FirstOrDefault();
            ComplaintModel complaint = new ComplaintModel();

            complaint.Id = data.Id;
            complaint.ComplaintStatus = Enum.GetName(typeof(ComplaintStatus), data.ComplaintStatusId);
            complaint.ComplaintType   = Enum.GetName(typeof(ComplaintType), data.ComplaintTypeId);
            complaint.Description     = data.Details;
            complaint.IncidentDate    = data.IncidentDate;
            complaint.Feedback        = data.Feedback;

            return(View(complaint));
        }
Example #19
0
        public static int UpdateComplaintStatus(int id,
                                                int complaintStatusId)
        {
            ComplaintModel data = new ComplaintModel
            {
                Id = id,
                ComplaintStatusId = complaintStatusId
            };

            string sql = @"UPDATE dbo.Complaint SET ComplaintStatusId = @ComplaintStatusId
                               WHERE Id = @Id;";

            return(SqlDataAccess.SaveData(sql, data));
        }
Example #20
0
        public ComplaintModel FindById(int complaintId)
        {
            ComplaintModel complaint = null;

            try
            {
                complaint = _repositoryContext.Complaint.Find(complaintId);
            }
            catch (Exception)
            {
                throw;
            }

            return(complaint);
        }
        public ComplaintModel FindById(int complaintId)
        {
            ComplaintModel complaint = null;

            try
            {
                complaint = _repositoryWrapper.ComplaintRepository.FindByCondition(x => x.Id == complaintId).FirstOrDefault();
            }
            catch (Exception)
            {
                throw;
            }

            return(complaint);
        }
Example #22
0
 public IHttpActionResult Put([FromBody] ComplaintModel model)
 {
     try
     {
         if (!ModelState.IsValid)
         {
             return(BadRequest(ModelState));
         }
         _complaintService.Update(model);
         return(Ok(model));
     }
     catch (Exception ec)
     {
         return(BadRequest(ec.Message));
     }
 }
Example #23
0
 public IHttpActionResult AddComplaint(ComplaintBindingModel model)
 {
     try
     {
         ComplaintBindingModel complaintBindingModel = new ComplaintBindingModel();
         ComplaintModel complaintModel = new ComplaintModel();
         AutoMapper.Mapper.Map(model,complaintModel);
         complaintModel = complaintService.InsertComplaint(complaintModel);
         AutoMapper.Mapper.Map(complaintModel, complaintBindingModel);
         return Ok(complaintBindingModel);
     }
     catch (Exception ex)
     {
         return BadRequest(ex.Message);
     }
 }
Example #24
0
        public ActionResult FileComplaint(ComplaintModel model)
        {
            if (ModelState.IsValid)
            {
                int recordsCreated = CreateComplaint(
                    (int)Session["TenantID"],
                    (int)Session["PropertyID"],
                    model.IncidentDate,
                    model.Description,
                    (int)Enum.Parse(typeof(ComplaintStatus), model.ComplaintStatus),
                    (int)Enum.Parse(typeof(ComplaintType), model.ComplaintType)
                    );
                return(View("SuccessfulComplaint", model));
            }

            return(View());
        }
Example #25
0
        public void Create(ComplaintModel model)
        {
            try
            {
                if (_complaintRepository.NameExist(model))
                {
                    throw new Exception("Complaint Already exist");
                }

                var complaint = Mapper.Map <ComplaintModel, Complaint>(model);
                _complaintRepository.Insert(complaint);
            }
            catch (Exception ec)
            {
                throw new Exception(ec.Message);
            }
        }
Example #26
0
        public IActionResult Delete(ComplaintModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    _service.Delete(model.Id);
                    return(Ok());
                }

                return(BadRequest(ModelState));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Example #27
0
        public IActionResult Update(ComplaintModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    _service.UpdateComplaint(model, GetCurrentUserId());
                    return(Ok(_service.GetById(model.Id)));
                }

                return(BadRequest(ModelState));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Example #28
0
        public ActionResult EditComplaint(ComplaintModel model)
        {
            if (ModelState.IsValid)
            {
                int recordUpdated = UpdateComplaint(
                    model.Id,
                    model.IncidentDate,
                    model.Description,
                    (int)Enum.Parse(typeof(ComplaintStatus), model.ComplaintStatus),
                    (int)Enum.Parse(typeof(ComplaintType), model.ComplaintType),
                    model.Feedback
                    );
                return(RedirectToAction("ViewComplaints"));
            }

            return(View());
        }
        public async Task <IActionResult> Create(int id)
        {
            Request request = await _dbContext.Requests.GetRequestForOtherViewsById(id);

            request.Complaints = await _dbContext.Complaints.GetComplaintsForRequest(id).ToListAsync();

            if ((await _authorizationService.AuthorizeAsync(User, request, Policies.CreateComplaint)).Succeeded)
            {
                if (!request.CanCreateComplaint(_clock.SwedenNow))
                {
                    _logger.LogWarning("Wrong status when trying to Create complaint. Status: {request.Status}, RequestId {request.RequestId}", request.Status, request.RequestId);
                    return(RedirectToAction("Index", "Home", new { errormessage = "Bokning är inte i rätt tillstånd för att kunna göra en reklamation" }));
                }
                return(View(ComplaintModel.GetModelFromRequest(request)));
            }
            return(Forbid());
        }
Example #30
0
        //[Authorize(Roles = "User")]
        public async Task <IActionResult> Post(ComplaintModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    model.ComplainBy = GetCurrentUserId();
                    _service.Create(model, model.ComplainBy);
                    return(Ok());
                }

                return(BadRequest(ModelState));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Example #31
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var settings   = DependencyService.Get <IAppSettings>();
            var Controller = EnumExtensionMethods.GetEnumDescription(UserRole.Controller);
            var Admin      = EnumExtensionMethods.GetEnumDescription(UserRole.Admin);
            var SiteAdmin  = EnumExtensionMethods.GetEnumDescription(UserRole.SiteAdmin);

            ComplaintModel status = (ComplaintModel)value;

            if ((settings.UserRole.Equals(Controller) || settings.UserRole.Equals(Admin) || settings.UserRole.Equals(SiteAdmin)) && status.ComplainStatus != (int)ComplaintStatusEnum.Registered && status.IsEmailSend == false)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        public string Post(ComplaintModel complaint)
        {
            try
            {
                complaint.ComplaintDate = DateTime.Now;
                bool isCreated = _complaintService.Create(complaint);
                if (isCreated)
                {
                    return(JsonConvert.SerializeObject(ApiResponseUtility.CreateSuccessResponse("Complaint Logged", isCreated)));
                }

                return(JsonConvert.SerializeObject(ApiResponseUtility.CreateSuccessResponse("Complaint Logged Unsucessful", isCreated)));
            }
            catch (Exception ex)
            {
                return(JsonConvert.SerializeObject(ApiResponseUtility.CreateErrorResponse(ex)));
            }
        }
Example #33
0
        public ComplaintModel GetComplaintDetailByComplaintId(int compliantId)
        {
            //unitOfWork.StartTransaction();
            ComplaintRepository repo = new ComplaintRepository(unitOfWork);
            ComplaintModel complaintModelList = new ComplaintModel();
            Complaint complaintlist = new Complaint();
            var complaints = (from data in db.Complaint
                              join e in db.Employee on data.EmployeeId equals e.EmployeeId
                              join cl in db.Client on data.ClientId equals cl.ClientId
                              join ul in db.UserLocation on cl.ClientId equals ul.UserId
                              join u in db.Users on cl.ClientId equals u.Id
                              join sp in db.ServiceProvider on data.ServiceProviderId equals sp.ServiceProviderId
                              join j in db.Job on data.JobId equals j.JobId
                              select new
                              {
                                  ComplainId = data.ComplaintId,
                                  Description = data.Description,
                                  ServiceProviderId = data.ServiceProviderId,
                                  EmployeeName = e.FirstName,
                                  ClientName = cl.FirstName,
                                  ClientAddress = ul.Address,
                                  ClientPhoneNumber = u.PhoneNumber,
                                  ServiceProviderName = sp.CompanyName,
                                  Status = data.Status,
                                  jobDescription = j.Description,
                                  JobAddress = j.JobAddress
                              }).Where(x => x.ComplainId == compliantId).FirstOrDefault();

                ComplaintModel model = new ComplaintModel();
                model.ComplaintId = complaints.ComplainId;
                model.Description = complaints.Description;
                model.EmployeeName = complaints.EmployeeName;
                model.ClientName = complaints.ClientName;
                model.ServiceProviderName = complaints.ServiceProviderName;
                model.Status = complaints.Status;
                model.JobDescription = complaints.jobDescription;
                model.JobAddress = complaints.JobAddress;
                model.ClientAddress = complaints.ClientAddress;
                model.ClientPhoneNumber = complaints.ClientPhoneNumber;

            //unitOfWork.Commit();
            return model;
        }
Example #34
0
        public bool Create(ComplaintModel complaint)
        {
            try
            {
                _repositoryContext.Complaint.Add(complaint);
                _repositoryContext.SaveChanges();

                if (complaint.Id > 0)
                {
                    return(true);
                }

                return(false);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Example #35
0
        public ActionResult EditComplaint(int id)
        {
            var            data      = LoadComplaint(id).FirstOrDefault();
            ComplaintModel complaint = new ComplaintModel();

            ////-
            //IEnumerable<SelectListItem> selectList = Enum.GetValues(typeof(ComplaintStatus));

            ////

            complaint.Id = data.Id;
            complaint.ComplaintStatus = Enum.GetName(typeof(ComplaintStatus), data.ComplaintStatusId);
            complaint.ComplaintType   = Enum.GetName(typeof(ComplaintType), data.ComplaintTypeId);
            complaint.Description     = data.Details;
            complaint.IncidentDate    = data.IncidentDate;
            complaint.Feedback        = data.Feedback;

            return(View(complaint));
        }
Example #36
0
 public IHttpActionResult GetComplaintByComplaintId(int complaintId)
 {
     ComplaintBindingModel complaintBindingModel = new ComplaintBindingModel();
     ComplaintModel complaintModel = new ComplaintModel();
     // AutoMapper.Mapper.Map(jobBindingModel, jobModel);
     complaintModel = complaintService.GetComplaintDetailByComplaintId(complaintId);
     AutoMapper.Mapper.Map(complaintModel, complaintBindingModel);
     return Ok(complaintBindingModel);
 }
Example #37
0
 public ComplaintModel InsertComplaint(ComplaintModel model)
 {
     //unitOfWork.StartTransaction();
     ComplaintRepository repo = new ComplaintRepository(unitOfWork);
     Complaint complaint = new Complaint();
     AutoMapper.Mapper.Map(model, complaint);
     repo.Insert(complaint);
     AutoMapper.Mapper.Map(complaint,model);
     //unitOfWork.Commit();
     return model;
 }
Example #38
0
 public ComplaintModel UpdateComplaint(ComplaintModel model)
 {
     //unitOfWork.StartTransaction();
     ComplaintRepository repo = new ComplaintRepository(unitOfWork);
     ComplaintModel complaintModel = new ComplaintModel();
     Complaint complaint = new Complaint();
     complaint = repo.GetAll().Where(x => x.ComplaintId == model.ComplaintId).FirstOrDefault();
     AutoMapper.Mapper.Map(model, complaint);
     repo.Update(complaint);
     //unitOfWork.Commit();
     return complaintModel;
 }
Example #39
0
        public ResponseMessage DeleteSelectedComplaints(List<string> complaints)
        {
            ResponseMessage responseMessage = new ResponseMessage();
            List<ComplaintModel> complaintModelList = new List<ComplaintModel>();
            ComplaintModel complaintModel = new ComplaintModel();
            try
            {

                foreach (var i in complaints)
                {
                    var id =Convert.ToInt32(i);
                    if (id >0)
                    {
                        //Delete Complaint
                        complaintService.DeleteComplaint(Convert.ToInt32(id));
                    }
                }

            }
            catch (Exception ex)
            {
                Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
                responseMessage.Message = ex.Message.ToString();
                return responseMessage;
            }

            responseMessage.Message = "Selected complaints deleted successfully.";
            return responseMessage;
        }
Example #40
0
 public IHttpActionResult UpdateComplaint(int complaintId)
 {
     try {
         ComplaintBindingModel complaintBindingModel = new ComplaintBindingModel();
         ComplaintModel complaintModel = new ComplaintModel();
         complaintModel = complaintService.GetComplaintByComplaintId(complaintId);
         complaintModel.Status = ComplaintStatus.Close;
         complaintModel = complaintService.UpdateComplaint(complaintModel);
         AutoMapper.Mapper.Map(complaintModel, complaintBindingModel);
         return Ok(complaintBindingModel);
     }
     catch(Exception ex)
     {
         return BadRequest(ex.Message);
     }
 }