Example #1
0
        public ActionResult CreateDepartment(Departments eDepartments)
        {
            string message = "";

            if (ModelState.IsValid)
            {
                try
                {
                    FASM_Enums.InfoMessages SaveResult = DepartmentsBI.SaveDepartments(ref eDepartments);
                    switch (SaveResult)
                    {
                    case FASM_Enums.InfoMessages.Success:
                        message = FASM_Msg.SuccessfulSaved;
                        break;

                    case FASM_Enums.InfoMessages.AlreadyExist:
                        message = "Sorry! the Department name already exist";
                        break;
                    }
                    return(Json(new { msg = message, JsonRequestBehavior.AllowGet }));
                }
                catch (Exception ex)
                {
                    ViewBag.CatchedMsg = ex.Message;
                }
            }

            return(View(eDepartments));
        }
Example #2
0
        public ActionResult EditDepartment(Departments eDepartments)
        {
            if (eDepartments.isLoad == false)
            {
                eDepartments.DepartmentId = Convert.ToInt32(Request.Params["DepartmentId"]);
                DepartmentsBI.LoadDepartments(ref eDepartments);
                return(PartialView(eDepartments));
            }
            else
            {
                string message = "";
                if (ModelState.IsValid)
                {
                    try
                    {
                        FASM_Enums.InfoMessages Results = DepartmentsBI.SaveDepartments(ref eDepartments);

                        switch (Results)
                        {
                        case FASM_Enums.InfoMessages.Success:
                            message = FASM_Msg.Updated;
                            break;

                        case FASM_Enums.InfoMessages.AlreadyExist:
                            message = "Sorry! the Department name already exist";
                            break;
                        }
                        return(Json(new { msg = message, JsonRequestBehavior.AllowGet }));
                    }
                    catch (Exception ex)
                    {
                        ViewBag.CatchedMsg = ex.Message;
                    }
                }
            }

            return(View(eDepartments));
        }