Example #1
0
        public ActionResult RequisitionList(DataTablesViewModel param, string fromDate, string toDate, string type)
        {
            try
            {
                if (!PermissionControl.CheckPermission(UserAppPermissions.Requisition_View))
                {
                    return(RedirectToAction("Restricted", "Home"));
                }

                if (string.IsNullOrEmpty(type) || type.Equals("undefined"))
                {
                    type = RequestStatus.My_Request;
                }

                DateTime frdate = DateTime.Now;
                if (!string.IsNullOrWhiteSpace(fromDate))
                {
                    frdate = DateTime.Parse(fromDate);
                }

                DateTime tdate = DateTime.Now;
                if (!string.IsNullOrWhiteSpace(toDate))
                {
                    tdate = DateTime.Parse(toDate);
                }


                logger.DebugFormat("Getting Requisition List with From Date [{0}] and To Date [{1}]", frdate.ToShortDateString(), tdate.ToShortDateString());

                IEnumerable <UserDepartment> userDepartments;
                bool IsAdmin = false;
                if (User.IsInRole("Admin"))
                {
                    IsAdmin = true;
                }

                var appUser = UserManager.FindById(User.Identity.GetUserId());
                userDepartments = userdepartmentManagement.GetAllUserDepartmentById(appUser.Id);


                RequisitionVM requisition = new RequisitionVM();
                requisition.DTObject = param;
                var list = requisitionManagement.GetAllRequisitionByParam(requisition, frdate, tdate, userDepartments, IsAdmin, type);
                logger.DebugFormat("Successfully Retrieve  Requisition List Records [{2}] with From Date [{0}] and To Date [1]", frdate.ToShortDateString(), tdate.ToShortDateString(), list.Count());

                return(Json(new
                {
                    sEcho = param.draw,
                    iTotalRecords = list.Select(i => i.DTObject.TotalRecordsCount).FirstOrDefault(),
                    iTotalDisplayRecords = list.Select(i => i.DTObject.TotalRecordsCount).FirstOrDefault(), // Filtered Count
                    aaData = list
                }));
            }
            catch (Exception ex)
            {
                logger.ErrorFormat("Exception Raised : Message[{0}] Stack Trace [{1}] ", ex.Message, ex.StackTrace);
                return(null);
            }
        }
Example #2
0
        public ActionResult AddEdit(string id)
        {
            ViewBag.Title = "Add/Update Users";

            var roleManager = new RoleManager <IdentityRole>(new RoleStore <IdentityRole>());
            var departments = departmentManagement.GetAllDepartments();
            var requisition = requisitionManagement.GetAllApprovedRequisition();
            var roles       = RoleManager.Roles.Where(x => !x.Name.Equals("Admin")).ToList().Select(x => new Core.ViewModel.SelectListItem()
            {
                Text  = x.Name,
                Value = x.Id
            });

            var user = new UserVM();

            user.RequisitionList = requisition;
            if (id != "0")
            {
                var appUser   = UserManager.FindById(id);
                var userRoles = UserManager.GetRoles(id);
                IEnumerable <UserDepartment> userDepartments = userdepartmentManagement.GetAllUserDepartmentById(appUser.Id);

                user.Id              = appUser.Id;
                user.FirstName       = appUser.FirstName;
                user.LastName        = appUser.LastName;
                user.Email           = appUser.Email;
                user.EmployeeNumber  = appUser.EmployeeNumber;
                user.Mobile          = appUser.Mobile;
                user.Designation     = appUser.Designation;
                user.UserPermissions = GetUserPermission(id);
                user.RequisitionID   = appUser.RequisitionID;
                if (userDepartments != null)
                {
                    foreach (var userDept in userDepartments)
                    {
                        userDept.Departments = departments;
                        userDept.RolesList   = roles;
                    }
                    user.UserDepartments = userDepartments;
                }
            }


            return(PartialView("_AddEditUser", user));
        }
Example #3
0
        public ActionResult UserTaskList(DataTablesViewModel param, string type)
        {
            try
            {
                if (!PermissionControl.CheckPermission(UserAppPermissions.UserTask_View))
                {
                    return(RedirectToAction("Restricted", "Home"));
                }

                if (string.IsNullOrEmpty(type))
                {
                    type = User.Identity.GetUserId();
                }

                logger.DebugFormat("Getting User Task List with Ticket Type [{0}]", type);


                UserTaskVM userTask = new UserTaskVM();
                userTask.DTObject = param;
                var userDepartments = userdepartmentManagement.GetAllUserDepartmentById(User.Identity.GetUserId());
                var list            = userTaskManagement.GetTaskByCriteria(userTask, type, userDepartments);
                logger.DebugFormat("Successfully Retrieve User Task List Records [{1}] with Ticket Type [{0}]", type, list.Count());


                return(Json(new
                {
                    sEcho = param.draw,
                    iTotalRecords = list.Select(i => i.DTObject.TotalRecordsCount).FirstOrDefault(),
                    iTotalDisplayRecords = list.Select(i => i.DTObject.TotalRecordsCount).FirstOrDefault(), // Filtered Count
                    aaData = list
                }));
            }
            catch (Exception ex)
            {
                logger.ErrorFormat("Exception Raised : Message[{0}] Stack Trace [{1}] ", ex.Message, ex.StackTrace);
                return(null);
            }
        }