コード例 #1
0
        public ActionResult CreateDataMenu(MenuViewModel paramAddMenu)
        {
            if (ModelState.IsValid)
            {
                //is delete default value
                paramAddMenu.isDelete = false;
                //update data manual createby and createdate
                paramAddMenu.createBy   = "Zack";
                paramAddMenu.createDate = DateTime.Now;


                int?numberV = MenuDataAccess.NameValidation(paramAddMenu.code);

                if (numberV == 0)
                {
                    string latestCode = MenuDataAccess.CreateMenu(paramAddMenu);

                    if (latestCode != "")
                    {
                        return(Json(new { success = true, latestCode, message = MenuDataAccess.Message }, JsonRequestBehavior.AllowGet));
                    }
                    else
                    {
                        return(Json(new { success = false, message = MenuDataAccess.Message }, JsonRequestBehavior.AllowGet));
                    }
                }
                else
                {
                    return(Json(new { success = false, message = "Menu name " + paramAddMenu.name + " is exist !" }, JsonRequestBehavior.AllowGet));
                }
            }
            else
            {
                return(Json(new { success = false, message = "Wajib menginputkan semua kotak bertanda bintang" }, JsonRequestBehavior.AllowGet));
            }
        }