Пример #1
0
        public ActionResult Edit(LoyaltyPointViewModel model)
        {
            if (ModelState.IsValid)
            {
                if (Request["Submit"] == "Save")
                {
                    var LoyaltyPoint = LoyaltyPointRepository.GetLoyaltyPointById(model.Id);
                    AutoMapper.Mapper.Map(model, LoyaltyPoint);
                    LoyaltyPoint.ModifiedUserId = WebSecurity.CurrentUserId;
                    LoyaltyPoint.ModifiedDate   = DateTime.Now;
                    LoyaltyPointRepository.UpdateLoyaltyPoint(LoyaltyPoint);

                    TempData[Globals.SuccessMessageKey] = App_GlobalResources.Wording.UpdateSuccess;
                    return(RedirectToAction("Index"));
                }

                return(View(model));
            }

            return(View(model));

            //if (Request.UrlReferrer != null)
            //    return Redirect(Request.UrlReferrer.AbsoluteUri);
            //return RedirectToAction("Index");
        }
Пример #2
0
        public ActionResult Create(LoyaltyPointViewModel model)
        {
            if (ModelState.IsValid)
            {
                var LoyaltyPoint = new LoyaltyPoint();
                AutoMapper.Mapper.Map(model, LoyaltyPoint);
                LoyaltyPoint.IsDeleted      = false;
                LoyaltyPoint.CreatedUserId  = WebSecurity.CurrentUserId;
                LoyaltyPoint.ModifiedUserId = WebSecurity.CurrentUserId;
                LoyaltyPoint.AssignedUserId = WebSecurity.CurrentUserId;
                LoyaltyPoint.CreatedDate    = DateTime.Now;
                LoyaltyPoint.ModifiedDate   = DateTime.Now;
                LoyaltyPointRepository.InsertLoyaltyPoint(LoyaltyPoint);

                TempData[Globals.SuccessMessageKey] = App_GlobalResources.Wording.InsertSuccess;
                return(RedirectToAction("Index"));
            }
            return(View(model));
        }
Пример #3
0
        public ActionResult Edit(int?Id)
        {
            var LoyaltyPoint = LoyaltyPointRepository.GetLoyaltyPointById(Id.Value);

            if (LoyaltyPoint != null && LoyaltyPoint.IsDeleted != true)
            {
                var model = new LoyaltyPointViewModel();
                AutoMapper.Mapper.Map(LoyaltyPoint, model);

                if (model.CreatedUserId != Helpers.Common.CurrentUser.Id && Helpers.Common.CurrentUser.UserTypeId != 1)
                {
                    TempData["FailedMessage"] = "NotOwner";
                    return(RedirectToAction("Index"));
                }

                return(View(model));
            }
            if (Request.UrlReferrer != null)
            {
                return(Redirect(Request.UrlReferrer.AbsoluteUri));
            }
            return(RedirectToAction("Index"));
        }
Пример #4
0
        public ViewResult Create()
        {
            var model = new LoyaltyPointViewModel();

            return(View(model));
        }