Exemple #1
0
        public JsonResult EditMerchantCategory(AddMerchantCategoryViewModel 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 merchant = db.MerchantCategory.Find(model.MerchantCategoryId);

                        merchant.MerchantCategoryId = model.MerchantCategoryId;
                        merchant.CategoryName       = model.CategoryName;
                        merchant.UpdatedBy          = MetadataServices.GetCurrentUser().Username;
                        merchant.UpdatedAt          = MetadataServices.GetCurrentDate();

                        db.SaveChanges();
                    }
                    return(Json(new { }, JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #2
0
        public JsonResult AddMerchantCategory(AddMerchantCategoryViewModel 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 newMerchantCategory = new MerchantCategory()
                    {
                        MerchantCategoryId = model.MerchantCategoryId,
                        CategoryName       = model.CategoryName,
                        CreatedBy          = MetadataServices.GetCurrentUser().Username,
                        CreatedAt          = MetadataServices.GetCurrentDate(),
                        UpdatedBy          = MetadataServices.GetCurrentUser().Username,
                        UpdatedAt          = MetadataServices.GetCurrentDate()
                    };
                    db.MerchantCategory.Add(newMerchantCategory);
                    db.SaveChanges();
                }
                return(Json(new { }, JsonRequestBehavior.AllowGet));
            }
        }