示例#1
0
        // GET: Return/Create
        public ActionResult Create()
        {
            try
            {
                var newReturn = new ReturnActionViewModel();

                GetNewSupplierActivation();
                GetNewModelsActivation();
                return View(newReturn);
            }
            catch (Exception ex)
            {
                return new HttpStatusCodeResult(HttpStatusCode.InternalServerError, ex.ToString());
            }
        }
示例#2
0
        public ActionResult Create(ReturnActionViewModel item)
        {
            try
            {
                if (item == null)
                    return RedirectToAction("Retrieve", "Return", new { message = ManageMessageId.Error });

                var newItem = new ReturnViewModel()
                {
                    OrderId = item.OrderId,
                    ReturnDate = item.ReturnDate,
                    ReturnMethod = item.ReturnMethod,
                    Reason = item.Reason,
                    Status = "Processing",
                    DtCreated = DateTime.UtcNow,
                    DtUpdated = DateTime.UtcNow
                };
                db.Returns.Add(newItem);
                db.SaveChanges();

                return RedirectToAction("Retrieve", "Return");
            }
            catch (Exception ex)
            {
                return new HttpStatusCodeResult(HttpStatusCode.InternalServerError, ex.ToString());
            }
        }
示例#3
0
        public ActionResult Edit(ReturnActionViewModel item)
        {
            try
            {
                //Refer to Product Controller for View
                ViewBag.ReturnStatusId = new SelectList(db.ReturnStatuses, "ReturnStatusId", "Status", item.ReturnStatusId);

                var itemToUpdate = new ReturnViewModel()
                {
                    ReturnId = item.ReturnId,
                    OrderId = item.OrderId,
                    ReturnDate = item.ReturnDate,
                    ReturnMethod = item.ReturnMethod,
                    Reason = item.Reason,
                    Status = (from rs in db.ReturnStatuses
                              where rs.ReturnStatusId == item.ReturnStatusId
                              select rs.Status).FirstOrDefault(),
                    DtCreated = item.DtCreated,
                    DtUpdated = item.DtUpdated
                };
                if (item.ReturnStatusId == 1)
                {
                    itemToUpdate.HasApproved = true;
                }
                else { itemToUpdate.HasApproved = false; }
                db.SaveChanges();
                return RedirectToAction("Retrieve", "Return", new { message = ManageMessageId.UpdateSuccess });
            }
            catch
            {
                return RedirectToAction("Retrieve", "Return", new { message = ManageMessageId.Error });
            }
        }
示例#4
0
        // GET: Return/Edit/5
        public ActionResult Edit(int id)
        {
            try
            {
                if (id < 1)
                    return RedirectToAction("Home", "Error404");

                var record = db.Returns.Where(x => x.ReturnId == id).FirstOrDefault();

                if (record == null)
                    return RedirectToAction("Home", "Error404");

                var itemToUpdate = new ReturnActionViewModel()
                {
                    ReturnId = record.ReturnId,
                    OrderId = record.OrderId,
                    ReturnDate = record.ReturnDate,
                    ReturnMethod = record.ReturnMethod,
                    Reason = record.Reason,
                    Status = record.Status,
                    DtCreated = record.DtCreated,
                    DtUpdated = record.DtUpdated
                };

                //Refer to Product Controller for View
                ViewBag.ReturnStatusId = new SelectList(db.ReturnStatuses, "ReturnStatusId", "Status");

                GetNewSupplierActivation();
                GetNewModelsActivation();
                return View(itemToUpdate);
            }
            catch (Exception ex)
            {
                return new HttpStatusCodeResult(HttpStatusCode.InternalServerError, ex.ToString());
            }
        }
        public ActionResult SupplierEditReturn(ReturnActionViewModel item)
        {
            try
            {
                var testReturnId = item;

                //Refer to Product Controller for View
                ViewBag.ReturnStatusId = new SelectList(db.ReturnStatuses, "ReturnStatusId", "Status", item.ReturnStatusId);

                var recordToUpdate = db.Returns.Where(r => r.ReturnId == item.ReturnId).FirstOrDefault();
                recordToUpdate.ReturnMethod = item.ReturnMethod;
                recordToUpdate.ReturnDate = item.ReturnDate;
                recordToUpdate.Status = (from rs in db.ReturnStatuses
                                         where rs.ReturnStatusId == item.ReturnStatusId
                                         select rs.Status).FirstOrDefault();
                recordToUpdate.DtUpdated = DateTime.UtcNow;
                recordToUpdate.Notification = "Customer";

                //var itemToUpdate = new ReturnActionViewModel()
                //{
                //    ReturnId = item.ReturnId,
                //    OrderId = item.OrderId,
                //    ReturnDate = item.ReturnDate,
                //    ReturnMethod = item.ReturnMethod,

                //    Reason = item.Reason,
                //    Status = (from rs in db.ReturnStatuses
                //              where rs.ReturnStatusId == item.ReturnStatusId
                //              select rs.Status).FirstOrDefault(),

                //    DtCreated = item.DtCreated,
                //    DtUpdated = DateTime.UtcNow
                //};
                db.SaveChanges();
                GetSupplierReturnNotification();
                GetSupplierNotification();
                return RedirectToAction("SupplierRetrieveReturns", "Supplier", new { message = ManageMessageId.UpdateReturnStatus });
            }
            catch
            {
                return View();
            }
        }
        public ActionResult SupplierEditReturn(int id)
        {
            string userId = User.Identity.GetUserId();
            if (userId == null)
            {
                return RedirectToAction("Login", "Account");
            }

            //View ReturnActionViewModel
            var record = (from r in db.Returns
                          join o in db.Orders on r.OrderId equals o.OrderId
                          where o.SupplierUserId == userId &&
                          r.ReturnId == id
                          select r).FirstOrDefault();

            var itemToUpdate = new ReturnActionViewModel()
            {
                ReturnId = record.ReturnId,
                OrderId = record.OrderId,
                ReturnDate = record.ReturnDate,
                ReturnMethod = record.ReturnMethod,
                Reason = record.Reason,
                Status = record.Status,
                DtCreated = record.DtCreated,
                DtUpdated = record.DtUpdated
            };

            //Refer to Product Controller for View
            ViewBag.ReturnStatusId = new SelectList(db.ReturnStatuses, "ReturnStatusId", "Status");
            GetSupplierReturnNotification();
            GetSupplierNotification();
            return View(itemToUpdate);
        }