コード例 #1
0
        public ActionResult Add(Category category)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    //_db.Categories.Add(category);
                    //_db.SaveChanges();

                    return Content(GetReturnAppWindow(Boolean.TrueString, "success", "Add Successfully."));
                }

                //return View(category);
                //return PartialView("_Create", category);
                return Content(GetReturnAppWindow(Boolean.FalseString, "warn", "Please review your form."));
            }
            catch (Exception ex)
            {
                return Content(GetReturnAppWindow(Boolean.FalseString, "error", "Error Occured!"));
            }
        }
コード例 #2
0
        public ActionResult Add(Category category)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    _db.Categories.Add(category);
                    _db.SaveChanges();

                    //return RedirectToAction("Index");
                    return Content(Boolean.TrueString);
                }

                //return View(category);
                //return PartialView("_Add", category);
                return Content("Please review your form.");
            }
            catch (Exception ex)
            {
                return Content("Error Occured!");
            }
        }
コード例 #3
0
        public JsonResult MasterDetailsSave(Category model, List<Product> modelList)
        {
            try
            {
                if (ModelState.IsValid)
                {

                    if (model != null)
                    {
                        if (modelList.Any())
                        {
                            //Save MasterDetails Data

                            //Save MasterDetails Data

                            return Json(new { msg = "Master details saved successfully.", status = MessageType.success.ToString() }, JsonRequestBehavior.AllowGet);
                        }
                        else
                        {
                            //Details Data Null Message
                            return Json(new { msg = "Details data could not found.", status = MessageType.success.ToString() }, JsonRequestBehavior.AllowGet);
                        }
                    }
                    else
                    {
                        //Master Data Null Message
                        return Json(new { msg = "Master data could not found.", status = MessageType.success.ToString() }, JsonRequestBehavior.AllowGet);
                    }

                }

                //ModelState Validation
                return Json(new { msg = ExceptionHelper.ModelStateErrorFormat(ModelState), status = MessageType.info.ToString() }, JsonRequestBehavior.AllowGet);

            }
            catch (Exception ex)
            {
                return Json(new { msg = ExceptionHelper.ExceptionMessageFormat(ex, log: false), status = MessageType.error.ToString() }, JsonRequestBehavior.AllowGet);
            }
        }
コード例 #4
0
        public ActionResult Update(Category category)
        {
            if (ModelState.IsValid)
            {
                _db.Entry(category).State = EntityState.Modified;
                _db.SaveChanges();
                return RedirectToAction("PopUp");
            }

            return View("PopUp");
        }
コード例 #5
0
        public ActionResult Edit(Category category)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    _db.Entry(category).State = EntityState.Modified;
                    _db.SaveChanges();

                    //return RedirectToAction("Index");
                    return Content(Boolean.TrueString);
                }

                //return View(category);
                //return PartialView("_Edit", category);
                return Content("Please review your form.");
            }
            catch (Exception ex)
            {
                return Content("Error Occured!");
            }
        }
コード例 #6
0
        public ActionResult Create(Category category)
        {
            if (ModelState.IsValid)
            {
                _db.Categories.Add(category);
                _db.SaveChanges();
                return RedirectToAction("PopUp");
            }

            return View("PopUp");
        }
コード例 #7
0
 public ActionResult Add()
 {
     var category = new Category();
     return PartialView("_Add", category);
 }