Ejemplo n.º 1
0
 public IActionResult WriteComplaint(ComplaintInsertVM complaintInsert)
 {
     if (ModelState.IsValid)
     {
         User currentUser = HttpContext.Session.Get <User>("currentUser");
         if (currentUser == null)
         {
             return(RedirectToAction("Index", "Login"));
         }
         //HttpContext.Session.Set<User>("currentUser", currentUser);
         //complaintInsert.UserID = currentUser.ID;
         Complaint complaint = new Complaint()
         {
             ComplaintTitle  = complaintInsert.Title,
             ComplaintDetail = complaintInsert.Detail,
             UserID          = currentUser.ID,
             CompanyID       = complaintInsert.CompanyID
         };
         if (complaint != null)
         {
             try
             {
                 complaintBLL.Add(complaint);
                 this._logger.LogInformation($"New complaint inserted by {currentUser.Email} and complaint id = {complaint.ID}.");
                 return(RedirectToAction("Index", "Home"));
             }
             catch (Exception)
             {
                 throw new Exception();
             }
         }
     }
     return(View());
 }
Ejemplo n.º 2
0
 public IActionResult WriteComplaint(int?id)
 {
     if (id != null)
     {
         ComplaintInsertVM complaintInsert = new ComplaintInsertVM();
         foreach (Company item in companyBLL.GetCompaniesBySubCatID(id.Value).Data)
         {
             complaintInsert.Companies.Add(new SelectListItem
             {
                 Text  = item.CompanyName,
                 Value = item.ID.ToString()
             });
         }
         return(View(complaintInsert));
     }
     return(View(GetComplaintInsertVM()));
 }
Ejemplo n.º 3
0
        ComplaintInsertVM GetComplaintInsertVM(Complaint complaint = null)
        {
            ComplaintInsertVM complaintInsert = new ComplaintInsertVM();

            foreach (Company item in companyBLL.GetAll().Data)
            {
                complaintInsert.Companies.Add(new SelectListItem
                {
                    Text  = item.CompanyName,
                    Value = item.ID.ToString()
                });
            }
            if (complaint != null)
            {
                complaintInsert.Title              = complaint.ComplaintTitle;
                complaintInsert.Detail             = complaint.ComplaintDetail;
                complaintInsert.UserID             = complaint.UserID;
                complaintInsert.ComplaintProofFile = complaint.ComplaintProofUrl;
                complaintInsert.IncoiceProofFile   = complaint.ComplaintInvoiceUrl;
                complaintInsert.CompanyID          = complaint.CompanyID;
            }
            return(complaintInsert);
        }