public ActionResult CreateDepartment(DepartmentPO createForm)
        {
            ActionResult result = null;

            if (Session["RoleID"] != null)
            {
                if ((int)Session["RoleID"] == 1 || (int)Session["RoleID"] == 2)
                {
                    if (ModelState.IsValid)
                    {
                        DepartmentDO mappedDataCreate = Mapper.MapDepartmentPOtoDO(createForm);
                        DepartmentDataAccessLayer.CreateDepartment(mappedDataCreate);
                        result = RedirectToAction("ViewAllDepartment");
                    }
                    else
                    {
                        result = View(createForm);
                    }
                }
                else
                {
                    result = RedirectToAction("Index", "Home");
                }
            }
            else
            {
                result = RedirectToAction("Index", "Home");
            }
            return(result);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="departmentId"></param>
        /// <param name="name"></param>
        /// <param name="description"></param>
        public void CreateDepartment(Guid departmentId, String name, String description)
        {
            try
            {
                Department department = new Department();
                department.Department_Id          = departmentId;
                department.Department_Name        = name;
                department.Department_Description = description;
                department.Department_IsDelete    = false;

                int result = DD.CreateDepartment(department);
                if (result == -1)
                {
                    throw new Exception("An error occurred while executing this operation.");
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Ejemplo n.º 3
0
 public string CreateDepartment(Department dep)
 {
     return(objdal.CreateDepartment(dep));
 }