예제 #1
0
        public void Update(ComplaintViewModel model)
        {
            var item = _db.Complaints.FirstOrDefault(x => x.ComplaintId == model.ComplaintId);

            if (item != null)
            {
                item.Company     = model.Company;
                item.SentDate    = model.SentDate;
                item.Title       = model.Title;
                item.WhatHappend = model.WhatHappend;

                item.ProductId = model.ProductId;

                _db.Entry(item).State = EntityState.Modified;
                _db.SaveChanges();

                var product = _db.Products.Find(model.ProductId);
                if (product == null)
                {
                    throw new ArgumentNullException("product");
                }

                model.Product = new ProductViewModel()
                {
                    ProductId = product.ProductId, Name = product.Name
                };
            }
        }
예제 #2
0
        //Sample code for ViewModel
        public ActionResult EditTwo(int id)
        {
            var complaints         = unitOfWork.ComplaintRepository.GetComplaintById(id);
            var complaintViewModel = new ComplaintViewModel(complaints);

            return(View(complaintViewModel));
        }
예제 #3
0
        // GET: Complaint
        public ActionResult Index()
        {
            List <ComplaintViewModel> lstCVM = new List <ComplaintViewModel>();
            List <complaint>          lst    = cs.getAll().ToList();

            foreach (complaint comp in lst)
            {
                ComplaintViewModel cm = new ComplaintViewModel();
                cm.id            = comp.id;
                cm.Description   = comp.Description;
                cm.creationDate  = comp.creationDate;
                cm.Subject       = comp.Subject;
                cm.importanceLvl = comp.importanceLvl;
                cm.MyUser_idUser = (int)comp.MyUser_idUser;
                cm.user          = us.GetById((int)comp.MyUser_idUser);
                lstCVM.Add(cm);
            }
            //List<string> lstS = new List<string>();
            //foreach (var item in Enum.GetValues(typeof(subjectType)))
            //{
            //    lstS.Add(item.ToString());
            //}
            //List<string> lstI = new List<string>();
            //foreach (var item in Enum.GetValues(typeof(importanceType)))
            //{
            //    lstI.Add(item.ToString());
            //}
            //ViewBag.subject = lstS.ToSelectListItems();//new SelectList(lstS, "string","string");
            //ViewBag.importance = lstI.ToSelectListItems();

            return(View(lstCVM));
        }
        public async Task <IActionResult> Create(ComplaintViewModel model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var user = await _userHelper.GetUserByUsernameAsync(User.Identity.Name);

                    if (user == null)
                    {
                        return(new NotFoundViewResult("_Error404Client"));
                    }

                    var clientComplaint = _clientConverterHelper.ToClientComplaint(model, true, user);

                    await _complaintRepository.CreateAsync(clientComplaint);

                    return(RedirectToAction("AccountManager"));
                }
                catch (Exception ex)
                {
                    ModelState.AddModelError(string.Empty, ex.Message);
                }
            }
            return(View(model));
        }
예제 #5
0
        //
        // GET: /Complaint/Details/5
        public ActionResult Details(int id)
        {
            try
            {
                con.Open();

                ComplaintViewModel viewModel = new ComplaintViewModel();
                viewModel.complaint = con.Query <Compliant>("SELECT * FROM Compliants WHERE ID = @ComID", new { ComID = id }).FirstOrDefault();
                int comID = con.Query <int>("SELECT Complainant_Id FROM Compliants WHERE ID = @ComID", new { ComID = id }).FirstOrDefault();
                viewModel.complainant    = con.Query <Complainant>("SELECT * FROM Complainants WHERE ID = @ComID", new { ComID = comID }).FirstOrDefault();
                viewModel.body_corporate = con.Query <BodyCorporate>("SELECT * FROM BodyCorporates WHERE Compliant_Id = @compl_Id", new { compl_Id = id }).FirstOrDefault();

                Representation rep = new Representation();
                rep = con.Query <Representation>("SELECT * FROM Representations WHERE ID = @ComID", new { ComID = comID }).FirstOrDefault();

                //viewModel.rep_doc = File(rep.Proof_of_Rep + "RepDoc_" + id, System.Net.Mime.MediaTypeNames.Application.Octet);

                ViewBag.repId = rep.Id;

                viewModel.advisor = con.Query <Advisor>("SELECT * FROM Advisors WHERE Representation_Id = @rep_id", new { rep_id = rep.Id }).FirstOrDefault();

                con.Close();

                return(View(viewModel));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #6
0
        public async Task <IActionResult> Post([FromBody] ComplaintViewModel vm)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var complaint = AutoMapper.Mapper.Map <Complaint>(vm);

                    _repository.AddCitizen(complaint.Citizen);
                    _repository.AddComplaint(complaint);

                    if (await _repository.SaveChangesAsync())
                    {
                        return(Created("/api/complaints", AutoMapper.Mapper.Map <ComplaintViewModel>(complaint)));
                    }
                }
                catch (Exception ex)
                {
                    return(BadRequest(string.Format("An exception was caught attempting " +
                                                    "to add new complaint. {0}", ex.ToString())));
                }
            }

            return(BadRequest("Failed to save the complaint"));
        }
예제 #7
0
        public ActionResult Update([DataSourceRequest] DataSourceRequest request, ComplaintViewModel model)
        {
            if (model != null && ModelState.IsValid)
            {
                _complaintService.Update(model);
            }

            return(Json(new[] { model }.ToDataSourceResult(request, ModelState)));
        }
예제 #8
0
        public ActionResult Destroy([DataSourceRequest] DataSourceRequest request, ComplaintViewModel model)
        {
            if (model != null)
            {
                _complaintService.Destroy(model);
            }

            return(Json(new[] { model }.ToDataSourceResult(request, ModelState)));
        }
예제 #9
0
        public void Destroy(ComplaintViewModel model)
        {
            var item = _db.Complaints.FirstOrDefault(x => x.ComplaintId == model.ComplaintId);

            if (item != null)
            {
                _db.Entry(item).State = EntityState.Deleted;
                _db.SaveChanges();
            }
        }
예제 #10
0
        public ActionResult Edit(int id, ComplaintViewModel comp)
        {
            complaint cm = cs.GetById(id);

            cm.Description   = comp.Description;
            cm.Subject       = comp.Subject;
            cm.importanceLvl = comp.importanceLvl;
            cs.Update(cm);
            cs.Commit();
            return(RedirectToAction("Index"));
        }
예제 #11
0
        public ActionResult Search(ComplaintViewModel cViewModel)
        {
            PaginationInfo pager = new PaginationInfo();

            if (TempData["cViewModel"] != null)
            {
                cViewModel = (ComplaintViewModel)TempData["cViewModel"];
            }
            pager = cViewModel.Pager;
            return(View("Search", cViewModel));
        }
예제 #12
0
        public ActionResult ShowComplaints()
        {
            if (Session["userType"] == null || Session["userType"].ToString() == "user")
            {
                return(RedirectToAction("Index", "Home"));
            }
            ComplaintViewModel cvm = new ComplaintViewModel();

            cvm.complaints = (new ComplaintsDal()).complaints.ToList <Complaint>();
            return(View(cvm));
        }
예제 #13
0
        // GET: Complaint/Delete/5
        public ActionResult Delete(int id)
        {
            complaint          comp = cs.GetById(id);
            ComplaintViewModel cm   = new ComplaintViewModel();

            cm.Description   = comp.Description;
            cm.creationDate  = comp.creationDate;
            cm.Subject       = comp.Subject;
            cm.importanceLvl = comp.importanceLvl;
            cm.MyUser_idUser = (int)comp.MyUser_idUser;
            cm.user          = us.GetById((int)comp.MyUser_idUser);
            return(View(cm));
        }
예제 #14
0
        public ComplaintViewModel ToComplaintClientViewModel(ClientComplaint clientComplaint)
        {
            var complaint = new ComplaintViewModel
            {
                Id        = clientComplaint.Id,
                Complaint = clientComplaint.Complaint,
                Email     = clientComplaint.CreatedBy.Email,
                Date      = clientComplaint.CreateDate,
                Body      = clientComplaint.Body,
                Status    = clientComplaint.Status,
                Reply     = clientComplaint.Reply
            };

            return(complaint); // todo diz que a lista vem a null
        }
예제 #15
0
        public ActionResult Create(ComplaintViewModel comp)
        {
            complaint c = new complaint();

            c.Description   = comp.Description;
            c.creationDate  = DateTime.Now;
            c.Subject       = comp.Subject;
            c.importanceLvl = comp.importanceLvl;
            c.MyUser_idUser = (int)comp.MyUser_idUser;
            //c.user = us.GetById((int)comp.MyUser_idUser);
            cs.Add(c);
            cs.Commit();

            return(RedirectToAction("Index"));
        }
예제 #16
0
        public ActionResult Index(ComplaintViewModel cViewModel)
        {
            PaginationInfo pager = new PaginationInfo();

            try
            {
                pager.IsPagingRequired = false;
            }
            catch (Exception ex)
            {
                cViewModel.Friendly_Message.Add(MessageStore.Get("SYS01"));
            }

            return(View("Index", cViewModel));
        }
예제 #17
0
        public void Create(ComplaintViewModel model)
        {
            var product = _db.Products.Find(model.ProductId);

            model.Product = new ProductViewModel()
            {
                ProductId = model.ProductId, Name = product?.Name
            };

            var entity = model.ConvertToDomainModel();

            entity.Product = product;

            _db.Complaints.Add(entity);
            _db.SaveChanges();
        }
예제 #18
0
        public ActionResult Get_Complaint_By_Id(ComplaintViewModel cViewModel)
        {
            PaginationInfo pager = new PaginationInfo();

            try
            {
                cViewModel.Complaint = _complaintMan.Get_Complaint_By_Id(cViewModel.Complaint_Id);

                cViewModel.Complaint.ComplaintLots = _complaintMan.Get_Complaint_Lot_Mappings(cViewModel.Complaint_Id);
            }
            catch (Exception ex)
            {
                cViewModel.Friendly_Message.Add(MessageStore.Get("SYS01"));
            }
            return(Index(cViewModel));
        }
예제 #19
0
        public ClientComplaint ToClientComplaint(ComplaintViewModel model, bool isNew, User user)
        {
            var client = new ClientComplaint
            {
                Id         = isNew ? 0 : model.Id,
                Complaint  = model.Complaint,
                Email      = user.Email,
                Date       = DateTime.UtcNow,
                Body       = model.Body,
                Status     = 1,
                CreateDate = DateTime.UtcNow,
                CreatedBy  = user
            };

            return(client);
        }
        public IActionResult Create()
        {
            var client = User.Identity.Name;

            if (client == null)
            {
                return(new NotFoundViewResult("_Error404Client"));
            }

            var model = new ComplaintViewModel
            {
                Complaints = _complaintRepository.GetComboComplaintTypes()
            };

            return(View(model));
        }
예제 #21
0
        public async Task <JsonResult> Create(ComplaintViewModel complaint)
        {
            try
            {
                using (ComplaintService complaintService = new ComplaintService())
                {
                    await complaintService.Create(complaint, User.Identity.GetUserId());
                }

                return(Json("Success", JsonRequestBehavior.AllowGet));
            }
            catch (System.Exception ex)
            {
                throw;
            }
        }
예제 #22
0
        // GET: Complaint/Create
        public ActionResult Create()
        {
            List <string> lst = new List <string>();

            foreach (var item in Enum.GetValues(typeof(subjectType)))
            {
                lst.Add(item.ToString());
            }
            ComplaintViewModel cm = new ComplaintViewModel()
            {
                importanceLvl = Enum.GetName(typeof(importanceType), importanceType.Low)
            };

            cm.subjectLst   = lst.ToSelectListItems2();
            cm.creationDate = DateTime.Now;
            return(View(cm));
        }
        public async Task <IActionResult> View(int id)
        {
            var complaint = await _dbContext.Complaints.GetFullComplaintById(id);

            if ((await _authorizationService.AuthorizeAsync(User, complaint, Policies.View)).Succeeded)
            {
                var isCustomer           = User.HasClaim(c => c.Type == TolkClaimTypes.CustomerOrganisationId);
                ComplaintViewModel model = ComplaintViewModel.GetViewModelFromComplaint(complaint, $"Complaint/{nameof(GetEventLog)}/{id}");
                model.IsBroker             = User.HasClaim(c => c.Type == TolkClaimTypes.BrokerId);
                model.IsCustomer           = isCustomer;
                model.IsAdmin              = User.IsInRole(Roles.SystemAdministrator);
                model.AllowAnwserOnDispute = !model.IsAdmin &&
                                             complaint.Status == ComplaintStatus.Disputed &&
                                             isCustomer &&
                                             (await _authorizationService.AuthorizeAsync(User, complaint, Policies.Accept)).Succeeded;
                return(PartialView(model));
            }
            return(Forbid());
        }
예제 #24
0
        public ActionResult Get_Complaint_Pre_Login(int customer_Id)
        {
            ComplaintViewModel cViewModel = new ComplaintViewModel();

            CustomerManager cMan = new CustomerManager();

            ComplaintManager _complaintMan = new ComplaintManager();

            PaginationInfo pager = new PaginationInfo();

            pager.IsPagingRequired = false;

            try
            {
                cViewModel.Complaint.Customer_Id = customer_Id;

                cViewModel.Complaint.Customer_Name = cMan.Get_Customer_By_Id(customer_Id).Customer_Name;

                cViewModel.Complaints = _complaintMan.Get_Complaints_By_Cust_Id(customer_Id, ref pager);

                if (TempData["cViewModel"] != null)
                {
                    cViewModel = (ComplaintViewModel)TempData["cViewModel"];

                    int Customer_Id = cViewModel.Complaint.Customer_Id;

                    string Customer_Name = cViewModel.Complaint.Customer_Name;

                    cViewModel.Complaint = new ComplaintInfo();

                    cViewModel.Complaint.Customer_Id = Customer_Id;

                    cViewModel.Complaint.Customer_Name = Customer_Name;
                }
            }
            catch (Exception ex)
            {
                cViewModel.Friendly_Message.Add(MessageStore.Get("SYS01"));
            }

            return(View("PreLoginComplaint", cViewModel));
        }
        public async Task <int> Create(ComplaintViewModel complaintViewModel, string createdBy)
        {
            using (ApplicationDbContext applicationDbContext = new ApplicationDbContext())
            {
                var complaint = AutoMapper.AutoMapperConfiguration.Mapper.Map <CMP.DataAccess.Model.Complaint>(complaintViewModel);

                complaint.CreateBy = createdBy;
                complaint.CreateOn = DateTime.Now;
                complaint.ComplaintStatuses.Add(new ComplaintStatus()
                {
                    ComplaintId = complaint.Id,
                    CreateBy    = createdBy,
                    CreateOn    = DateTime.Now,
                    Status      = (int)ComplaintStatusEnum.Pending
                });

                applicationDbContext.Complaints.Add(complaint);
                return(await applicationDbContext.SaveChangesAsync());
            }
        }
예제 #26
0
        public ActionResult Insert(ComplaintViewModel cViewModel)
        {
            try
            {
                cViewModel.Complaint.CreatedBy    = ((UserInfo)Session["User"]).UserId;
                cViewModel.Complaint.UpdatedBy    = ((UserInfo)Session["User"]).UserId;
                cViewModel.Complaint.CreatedOn    = DateTime.Now;
                cViewModel.Complaint.UpdatedOn    = DateTime.Now;
                cViewModel.Complaint.Complaint_Id = _complaintMan.Insert_Complaint(cViewModel.Complaint);

                foreach (var item in cViewModel.Lot_No.Trim(',').Split(','))
                {
                    cViewModel.Complaint.ComplaintLots.Add(new ComplaintLotMappingInfo {
                        Lot_No = Convert.ToInt32(item)
                    });
                }

                foreach (var item in cViewModel.Complaint.ComplaintLots)
                {
                    item.Complaint_Id = cViewModel.Complaint.Complaint_Id;

                    item.CreatedBy = ((UserInfo)Session["User"]).UserId;

                    item.UpdatedBy = ((UserInfo)Session["User"]).UserId;

                    item.CreatedOn = DateTime.Now;

                    item.UpdatedOn = DateTime.Now;

                    _complaintMan.Insert_Complaint_Lot_Mapping(item);
                }

                cViewModel.Friendly_Message.Add(MessageStore.Get("COM001"));
            }
            catch (Exception ex)
            {
                cViewModel.Friendly_Message.Add(MessageStore.Get("SYS01"));
            }
            TempData["cViewModel"] = cViewModel;
            return(RedirectToAction("Search"));
        }
예제 #27
0
        // GET: Complaint/Edit/5
        public ActionResult Edit(int id)
        {
            List <string> lst = new List <string>();

            foreach (var item in Enum.GetValues(typeof(subjectType)))
            {
                lst.Add(item.ToString());
            }
            complaint          comp = cs.GetById(id);
            ComplaintViewModel cm   = new ComplaintViewModel();

            cm.Description   = comp.Description;
            cm.creationDate  = comp.creationDate;
            cm.Subject       = comp.Subject;
            cm.subjectLst    = lst.ToSelectListItems2();
            cm.importanceLvl = comp.importanceLvl;
            cm.MyUser_idUser = (int)comp.MyUser_idUser;
            cm.user          = us.GetById((int)comp.MyUser_idUser);

            return(View(cm));
        }
예제 #28
0
 public ActionResult Index(string lstSubject, string lstImportance, string radio, DateTime?searchDate = null)
 {
     try
     {
         List <complaint>          lst = new List <complaint>();
         List <ComplaintViewModel> ll  = new List <ComplaintViewModel>();
         if (radio.Equals("sujet"))
         {
             lst = cs.complaintsBySubject(lstSubject).ToList();
         }
         else if (radio.Equals("importance"))
         {
             lst = cs.complaintsByImportance(lstImportance).ToList();
         }
         else if (radio.Equals("day") && searchDate != null)
         {
             lst = cs.ComplaintsByDay((DateTime)searchDate).ToList();
         }
         else if (radio.Equals("month") && searchDate != null)
         {
             lst = cs.complaintsByMonth((DateTime )searchDate).ToList();
         }
         foreach (complaint comp in lst)
         {
             ComplaintViewModel cm = new ComplaintViewModel();
             cm.id            = comp.id;
             cm.Description   = comp.Description;
             cm.creationDate  = comp.creationDate;
             cm.Subject       = comp.Subject;
             cm.importanceLvl = comp.importanceLvl;
             cm.MyUser_idUser = (int)comp.MyUser_idUser;
             cm.user          = us.GetById((int)comp.MyUser_idUser);
             ll.Add(cm);
         }
         return(View(ll));
     }catch
     {
         return(View());
     }
 }
예제 #29
0
        public ActionResult Insert_Complaint_Pre_Login(ComplaintViewModel cViewModel)
        {
            try
            {
                cViewModel.Complaint.CreatedOn    = DateTime.Now;
                cViewModel.Complaint.UpdatedOn    = DateTime.Now;
                cViewModel.Complaint.Complaint_Id = _complaintMan.Insert_Complaint(cViewModel.Complaint);

                foreach (var item in cViewModel.Lot_No.Trim(',').Split(','))
                {
                    cViewModel.Complaint.ComplaintLots.Add(new ComplaintLotMappingInfo {
                        Lot_No = Convert.ToInt32(item)
                    });
                }

                foreach (var item in cViewModel.Complaint.ComplaintLots)
                {
                    item.Complaint_Id = cViewModel.Complaint.Complaint_Id;

                    item.CreatedOn = DateTime.Now;

                    item.UpdatedOn = DateTime.Now;

                    _complaintMan.Insert_Complaint_Lot_Mapping(item);
                }

                // cViewModel.Complaint = new ComplaintInfo();


                cViewModel.Friendly_Message.Add(MessageStore.Get("COM001"));

                TempData["cViewModel"] = cViewModel;
            }
            catch (Exception ex)
            {
                cViewModel.Friendly_Message.Add(MessageStore.Get("SYS01"));
            }

            return(Get_Complaint_Pre_Login(cViewModel.Complaint.Customer_Id));
        }
예제 #30
0
        public JsonResult Get_Complaints(ComplaintViewModel cViewModel)
        {
            PaginationInfo pager = new PaginationInfo();

            pager = cViewModel.Pager;
            try
            {
                if (cViewModel.Filter.Customer_Id != 0)
                {
                    cViewModel.Complaints = _complaintMan.Get_Complaints_By_Cust_Id(cViewModel.Filter.Customer_Id, ref pager);
                }
                else
                {
                    cViewModel.Complaints = _complaintMan.Get_Complaints(ref pager);
                }
                cViewModel.Pager.PageHtmlString = PageHelper.NumericPager("javascript:PageMore({0})", cViewModel.Pager.TotalRecords, cViewModel.Pager.CurrentPage + 1, cViewModel.Pager.PageSize, 10, true);
            }
            catch (Exception ex)
            {
                cViewModel.Friendly_Message.Add(MessageStore.Get("SYS01"));
            }
            return(Json(cViewModel, JsonRequestBehavior.AllowGet));
        }