示例#1
0
        public ActionResult Create(VMRole paramModel)
        {
            try
            {
                RoleRepo.Message = string.Empty;

                //Create auto generate product_code
                using (var db = new Markom_IDLEEntities())
                {
                    string nol    = "";
                    m_role cek    = db.m_role.OrderByDescending(x => x.code).First();
                    int    simpan = int.Parse(cek.code.Substring(3));
                    simpan++;
                    for (int i = simpan.ToString().Length; i < 4; i++)
                    {
                        nol = nol + "0";
                    }
                    paramModel.code = "MN" + nol + simpan;
                }

                paramModel.created_by   = "Administrator";
                paramModel.created_date = DateTime.Now;
                paramModel.is_delete    = false;

                if (null == paramModel.name)
                {
                    RoleRepo.Message = "Anda belum memasukan semua data. Silahkan ulangi kembali";
                }
                if (string.IsNullOrEmpty(RoleRepo.Message))
                {
                    return(Json(new
                    {
                        success = RoleRepo.Insert(paramModel),
                        message = paramModel.code
                    }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(Json(new { success = false, message = RoleRepo.Message },
                                JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception hasError)
            {
                return(Json(new { success = false, message = hasError.Message },
                            JsonRequestBehavior.AllowGet));
            }
        }
示例#2
0
        public JsonResult Insert(RoleViewModel rViewModel)
        {
            try
            {
                Set_Date_Session(rViewModel.Role);

                foreach (var item in rViewModel.Role.Modules)
                {
                    Set_Date_Session(item);
                }
                rViewModel.Role.RoleId = _rRepo.Insert(rViewModel.Role);

                rViewModel.FriendlyMessage.Add(MessageStore.Get("Ro01"));
            }
            catch (Exception ex)
            {
                rViewModel.FriendlyMessage.Add(MessageStore.Get("SYS01"));

                Logger.Error("Role Controller - Insert " + ex.Message);
            }

            return(Json(rViewModel));
        }
示例#3
0
 public int InsertRole(RoleInfo role)
 {
     return(_roleRepo.Insert(role));
 }