Beispiel #1
0
        public IActionResult UpdateComplaint(long Id)
        {
            bool IsAdmin = _unitOfWork.Complaints.GetAll().Where(a => a.Id == Id).Select(a => a.IsAdmin).FirstOrDefault();
            //string uNameId = _unitOfWork.Complaints.GetAll().Where(a => a.Id == Id).Select(a => a.UserNameId).FirstOrDefault();
            ComplaintsVM complaintsVM;

            complaintsVM = new ComplaintsVM()
            {
                complaints = _unitOfWork.Complaints.GetAll().Where(a => a.Id == Id).FirstOrDefault(),
                OrdersList = _unitOfWork.Order.GetAll().Where(a => a.OrderStatus == SD.OrderStatusDone).
                             Select(i => new SelectListItem
                {
                    Text  = i.CustName + "- Id: " + i.Id,
                    Value = i.Id.ToString()
                }),
                StoresList = _unitOfWork.UserStoreName.GetAll().Where(a => a.UserNameId == returnUserNameId()).
                             Select(i => new SelectListItem
                {
                    Text  = i.StoreName,
                    Value = i.Id.ToString()
                })
            };
            ViewBag.IsAdmin = IsAdmin;
            return(View(complaintsVM));
        }
Beispiel #2
0
        public IActionResult UpdateComplaint(long Id)
        {
            bool         IsAdmin = _unitOfWork.Complaints.GetAll().Where(a => a.Id == Id).Select(a => a.IsAdmin).FirstOrDefault();
            Complaints   comp    = _unitOfWork.Complaints.GetAll().Where(a => a.Id == Id).FirstOrDefault();
            string       uNameId = comp.UserNameId;
            ComplaintsVM complaintsVM;

            complaintsVM = new ComplaintsVM()
            {
                complaints = _unitOfWork.Complaints.GetAll().Where(a => a.Id == Id).FirstOrDefault(),
                OrdersList = _unitOfWork.Order.GetAll().Where(a => a.Id == comp.OrderId).
                             Select(i => new SelectListItem
                {
                    Text  = i.CustName + "- Id: " + i.Id,
                    Value = i.Id.ToString()
                }),
                StoresList = _unitOfWork.UserStoreName.GetAll().Where(a => a.IsAdminStore).
                             Select(i => new SelectListItem
                {
                    Text  = i.StoreName,
                    Value = i.Id.ToString()
                })
            };
            ViewBag.IsAdmin = IsAdmin;
            if (complaintsVM.complaints.OrderId == 0)
            {
                complaintsVM.GeneralNotOrderRelated = true;
            }
            else
            {
                complaintsVM.GeneralNotOrderRelated = false;
            }
            return(View(complaintsVM));
        }
Beispiel #3
0
        public IActionResult AddComplaint(ComplaintsVM complaintsVM)
        {
            if (ModelState.IsValid)
            {
                //   complaintsVM.complaints.IsAdmin = _unitOfWork.Order.GetAll().Where(a => a.Id == complaintsVM.complaints.OrderId).
                //     Select(a => a.IsAdmin).FirstOrDefault();
                complaintsVM.complaints.IsAdmin    = true;
                complaintsVM.complaints.UserNameId = returnUserNameId();
                if (complaintsVM.complaints.Id == 0)
                {
                    if (complaintsVM.GeneralNotOrderRelated)
                    {
                        complaintsVM.complaints.OrderId = 0;
                    }
                    else//if its not a general ticket, get the storeid based on order
                    {
                        complaintsVM.complaints.StoreId =
                            _unitOfWork.Order.GetAll().Where(a => a.Id == complaintsVM.complaints.OrderId).Select(a => a.StoreNameId).
                            FirstOrDefault();;
                    }
                    _unitOfWork.Complaints.Add(complaintsVM.complaints);
                }
                else
                {
                    if (complaintsVM.GeneralNotOrderRelated)
                    {
                        complaintsVM.complaints.OrderId = 0;
                        complaintsVM.complaints.StoreId = 0;
                    }
                    _unitOfWork.Complaints.update(complaintsVM.complaints);
                }

                _unitOfWork.Save();
                ViewBag.ShowMsg = 1;


                //return RedirectToAction(nameof(Index));
            }
            ComplaintsVM complaintsVM2 = new ComplaintsVM()
            {
                complaints = new Complaints(),
                OrdersList = _unitOfWork.Order.GetAll().Where(a => a.UserNameId == returnUserNameId()).Where(a => a.OrderStatus == SD.OrderStatusDone).
                             Select(i => new SelectListItem
                {
                    Text  = i.CustName + "- Id: " + i.Id,
                    Value = i.Id.ToString()
                }),
                StoresList = _unitOfWork.UserStoreName.GetAll().Where(a => a.IsAdminStore).
                             Select(i => new SelectListItem
                {
                    Text  = i.StoreName,
                    Value = i.Id.ToString()
                })
            };

            return(View(complaintsVM2));
        }
Beispiel #4
0
        public IActionResult UpdateComplaint(ComplaintsVM complaintsVM)
        {
            if (ModelState.IsValid)
            {
                complaintsVM.complaints.HandledBy =
                    (_unitOfWork.ApplicationUser.GetAll().Where(q => q.UserName == User.Identity.Name).Select(q => q.Name)).FirstOrDefault();
                //if tracking number is not empty, complaint is solved
                if (complaintsVM.complaints.NewTrackingNumber != null)
                {
                    complaintsVM.complaints.Solved = true;
                }
                ViewBag.ShowMsg = 1;
                if (complaintsVM.complaints.NewTrackingNumber == null && complaintsVM.complaints.Solved &&
                    complaintsVM.complaints.SolutionDesc == null)
                {
                    ViewBag.ProvideSolution = true;
                }
                else
                {
                    ViewBag.ProvideSolution = false;
                    _unitOfWork.Complaints.update(complaintsVM.complaints);
                    _unitOfWork.Save();
                }

                //return RedirectToAction(nameof(Index));
            }
            ComplaintsVM complaintsVM2;

            complaintsVM2 = new ComplaintsVM()
            {
                complaints = _unitOfWork.Complaints.GetAll().Where(a => a.Id == complaintsVM.complaints.Id).FirstOrDefault(),
                OrdersList = _unitOfWork.Order.GetAll().Where(a => a.IsAdmin).Where(a => a.OrderStatus == SD.OrderStatusDone).
                             Select(i => new SelectListItem
                {
                    Text  = i.CustName + "- Id: " + i.Id,
                    Value = i.Id.ToString()
                }),
                StoresList = _unitOfWork.UserStoreName.GetAll().Where(a => a.UserNameId == returnUserNameId()).
                             Select(i => new SelectListItem
                {
                    Text  = i.StoreName,
                    Value = i.Id.ToString()
                })
            };
            if (complaintsVM.complaints.OrderId == 0)
            {
                complaintsVM.GeneralNotOrderRelated = true;
            }
            else
            {
                complaintsVM.GeneralNotOrderRelated = false;
            }
            ViewBag.IsAdmin = complaintsVM2.complaints.IsAdmin;
            return(View(complaintsVM2));
        }
        public IActionResult AddComplaint(long?Id)
        {
            ComplaintsVM complaintsVM;
            string       uNameId = "";
            string       uName   = "";

            uNameId = returnUserNameId();
            uName   = (_unitOfWork.ApplicationUser.GetAll().Where(q => q.UserName == User.Identity.Name).Select(q => q.UserName)).FirstOrDefault();
            if (Id == null)
            {
                complaintsVM = new ComplaintsVM()
                {
                    complaints = new Complaints(),
                    OrdersList = _unitOfWork.Complaints.getAllOrdersOfUser(uNameId).Select(i => new SelectListItem
                    {
                        Text  = i.CustName + "- Id: " + i.Id,
                        Value = i.Id.ToString()
                    }),
                    StoresList = _unitOfWork.UserStoreName.GetAll().Where(a => a.UserNameId == returnUserNameId()).
                                 Select(i => new SelectListItem
                    {
                        Text  = i.StoreName,
                        Value = i.Id.ToString()
                    })
                };
            }
            else
            {
                complaintsVM = new ComplaintsVM()
                {
                    complaints = new Complaints(),
                    OrdersList = _unitOfWork.Order.GetAll().Where(a => a.Id == Id).Select(i => new SelectListItem
                    {
                        Text  = i.CustName + "- Id: " + i.Id,
                        Value = i.Id.ToString()
                    }),
                    StoresList = _unitOfWork.UserStoreName.GetAll().Where(a => a.UserNameId == returnUserNameId()).
                                 Select(i => new SelectListItem
                    {
                        Text  = i.StoreName,
                        Value = i.Id.ToString()
                    })
                };
                complaintsVM.complaints.OrderId = Id;
            }

            ViewBag.UNameId = uNameId;
            ViewBag.sysDate = DateTime.Now;
            ViewBag.ShowMsg = 0;
            ViewBag.failed  = false;
            return(View(complaintsVM));
        }
        public IActionResult UpdateComplaint(long Id)
        {
            ComplaintsVM complaintsVM;
            string       uNameId = "";
            string       uName   = "";

            uNameId = returnUserNameId();
            uName   = (_unitOfWork.ApplicationUser.GetAll().Where(q => q.UserName == User.Identity.Name).Select(q => q.UserName)).FirstOrDefault();

            complaintsVM = new ComplaintsVM()
            {
                complaints = _unitOfWork.Complaints.GetAll().Where(a => a.Id == Id).FirstOrDefault(),
                OrdersList = _unitOfWork.Order.GetAll().Where(a => a.UserNameId == uNameId).Select(i => new SelectListItem
                {
                    Text  = i.CustName + "- Id: " + i.Id,
                    Value = i.Id.ToString()
                }),
                StoresList = _unitOfWork.UserStoreName.GetAll().Where(a => a.UserNameId == returnUserNameId()).
                             Select(i => new SelectListItem
                {
                    Text  = i.StoreName,
                    Value = i.Id.ToString()
                })
            };
            if (complaintsVM.complaints.OrderId == 0)
            {
                complaintsVM.GeneralNotOrderRelated = true;
            }
            else
            {
                complaintsVM.GeneralNotOrderRelated = false;
            }
            ViewBag.UNameId = uNameId;
            ViewBag.ShowMsg = 0;
            ViewBag.failed  = false;
            return(View(complaintsVM));
        }
        public IActionResult UpdateComplaint(ComplaintsVM complaintsVM)
        {
            if (ModelState.IsValid)
            {
                if (complaintsVM.complaints.Id != 0)
                {
                    if (complaintsVM.GeneralNotOrderRelated)
                    {
                        complaintsVM.complaints.OrderId = 0;
                    }
                    _unitOfWork.Complaints.update(complaintsVM.complaints);
                }
                _unitOfWork.Save();
                //  ViewBag.storeExist = storeExist;
                ViewBag.ShowMsg = 1;
            }
            ComplaintsVM complaintsVM2 = new ComplaintsVM()
            {
                complaints = new Complaints(),
                OrdersList = _unitOfWork.Order.GetAll().
                             Where(a => a.UserNameId == returnUserNameId()).Where(a => a.OrderStatus == SD.OrderStatusDone).
                             Select(i => new SelectListItem
                {
                    Text  = i.CustName + "- Id: " + i.Id,
                    Value = i.Id.ToString()
                }),
                StoresList = _unitOfWork.UserStoreName.GetAll().Where(a => a.UserNameId == returnUserNameId()).
                             Select(i => new SelectListItem
                {
                    Text  = i.StoreName,
                    Value = i.Id.ToString()
                })
            };

            return(View(complaintsVM2));
        }
        public IActionResult AddComplaint(ComplaintsVM complaintsVM)
        {
            //userStoreName.UserNameId =
            //(_unitOfWork.ApplicationUser.GetAll().Where(q => q.UserName == User.Identity.Name).Select(q => q.Id)).FirstOrDefault();
            //bool storeExist = _unitOfWork.UserStoreName.GetAll().Where(q => q.UserNameId == userStoreName.UserNameId)
            //       .Any(q => q.StoreName.Equals(userStoreName.StoreName, StringComparison.InvariantCultureIgnoreCase));
            //userStoreName.UserName = User.Identity.Name;
            //userStoreName.IsAdminStore = false;
            var errors = ModelState.Where(x => x.Value.Errors.Count > 0).Select(x => new { x.Key, x.Value.Errors }).ToArray();

            if (ModelState.IsValid)
            {
                if (complaintsVM.complaints.Id == 0)
                {
                    if (complaintsVM.GeneralNotOrderRelated)
                    {
                        complaintsVM.complaints.OrderId = 0;
                    }
                    else//if its not a general ticket, get the storeid based on order
                    {
                        complaintsVM.complaints.StoreId =
                            _unitOfWork.Order.GetAll().Where(a => a.Id == complaintsVM.complaints.OrderId).Select(a => a.StoreNameId).
                            FirstOrDefault();;
                    }
                    _unitOfWork.Complaints.Add(complaintsVM.complaints);
                }
                else
                {
                    if (complaintsVM.GeneralNotOrderRelated)
                    {
                        complaintsVM.complaints.OrderId = 0;
                        //complaintsVM.complaints.StoreId = 0;
                    }
                    _unitOfWork.Complaints.update(complaintsVM.complaints);
                }
                _unitOfWork.Save();
                //  ViewBag.storeExist = storeExist;
                ViewBag.ShowMsg = 1;


                //return RedirectToAction(nameof(Index));
            }
            ComplaintsVM complaintsVM2 = new ComplaintsVM()
            {
                complaints = new Complaints(),
                OrdersList = _unitOfWork.Order.GetAll().Where(a => a.UserNameId == returnUserNameId()).Where(a => a.OrderStatus == SD.OrderStatusDone).
                             Select(i => new SelectListItem
                {
                    Text  = i.CustName + "- Id: " + i.Id,
                    Value = i.Id.ToString()
                }),
                StoresList = _unitOfWork.UserStoreName.GetAll().Where(a => a.UserNameId == returnUserNameId()).
                             Select(i => new SelectListItem
                {
                    Text  = i.StoreName,
                    Value = i.Id.ToString()
                })
            };

            return(View(complaintsVM2));
        }