Пример #1
0
        public JsonResult EditMerchantPromotion(AddMerchantPromotionViewModel model)
        {
            try
            {
                using (var db = new TourEntities())
                {
                    var formsAuthentication = HttpContext.Request.Cookies[FormsAuthentication.FormsCookieName] != null
                  ? FormsAuthentication.Decrypt(
                        HttpContext.Request.Cookies[FormsAuthentication.FormsCookieName].Value)
                  : null;

                    if (ModelState.IsValid)
                    {
                        var merchantPromo = db.MerchantPromotion.Find(model.MerchantPromotionId);

                        merchantPromo.MechantId = model.MerchantId;
                        merchantPromo.MerchantPromotionDetail = model.MerchantPromotionDetail;
                        merchantPromo.UpdatedBy = MetadataServices.GetCurrentUser().Username;
                        merchantPromo.UpdatedAt = MetadataServices.GetCurrentDate();

                        db.SaveChanges();
                    }
                    return(Json(new { }, JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #2
0
        public JsonResult AddMerchantPromotion(AddMerchantPromotionViewModel model)
        {
            using (var db = new TourEntities())
            {
                if (ModelState.IsValid)
                {
                    var formsAuthentication = HttpContext.Request.Cookies[FormsAuthentication.FormsCookieName] != null
                    ? FormsAuthentication.Decrypt(
                        HttpContext.Request.Cookies[FormsAuthentication.FormsCookieName].Value)
                    : null;

                    var newMerchantPromotion = new MerchantPromotion()
                    {
                        MechantId = model.MerchantId,
                        MerchantPromotionDetail = model.MerchantPromotionDetail,
                        CreatedBy = MetadataServices.GetCurrentUser().Username,
                        CreatedAt = MetadataServices.GetCurrentDate(),
                        UpdatedBy = MetadataServices.GetCurrentUser().Username,
                        UpdatedAt = MetadataServices.GetCurrentDate()
                    };
                    db.MerchantPromotion.Add(newMerchantPromotion);
                    db.SaveChanges();
                }
                return(Json(new { }, JsonRequestBehavior.AllowGet));
            }
        }
Пример #3
0
        public ActionResult AddMerchantPromotion()
        {
            AddMerchantPromotionViewModel addMerchantPromoViewModel = new AddMerchantPromotionViewModel();

            List <int> merchantId = new List <int>();

            using (var db = new TourEntities())
            {
                addMerchantPromoViewModel.MerchantIdList = db.Merchant.Select(e => new SelectListItem()
                {
                    Text  = e.MerchantName.ToString(),
                    Value = e.MerchantId.ToString(),
                }).ToList();
            }

            return(View(addMerchantPromoViewModel));
        }