コード例 #1
0
        public ActionResult _Edit(Fiesta_Employee model)
        {
            bool modelIsValid = true;

            if (string.IsNullOrEmpty(model.FirstName))
            {
                ModelState.AddModelError("FirstName", "Required");
                modelIsValid = false;
            }
            if (string.IsNullOrEmpty(model.LastName))
            {
                ModelState.AddModelError("LastName", "Required");
                modelIsValid = false;
            }

            if (modelIsValid)
            {
                var original = db.Fiesta_Employee.FirstOrDefault(x => x.EmpId == model.EmpId);
                original.FirstName    = model.FirstName;
                original.LastName     = model.LastName;
                original.EmailAddress = model.EmailAddress;
                original.IsActive     = model.IsActive;
                original.ModifiedDate = DateTime.Now;
                db.SaveChanges();

                return(Json("Success", JsonRequestBehavior.AllowGet));
            }

            return(PartialView(model));
        }
コード例 #2
0
        public ActionResult AddStore(Store objStore)
        {
            var res = string.Empty;

            //      using (fze = new FiestaZohoDatabaseEntities())
            //{
            //     res = fze.AddStore(objStore.StateId,objStore.StoreNumber, objStore.Address, objStore.City, objStore.ZipCode).FirstOrDefault();
            //}
            if (!Exists(objStore))
            {
                var newStore = SetValues(objStore);
                db.Fiesta_Store.Add(newStore);
                db.SaveChanges();
            }
            else
            {
                res = "Store Already Exists.";
            }
            return(Json(res, JsonRequestBehavior.AllowGet));
        }