Beispiel #1
0
        public JsonResult GetAdminRoles()
        {
            string LoginUser = (string)Session["LoginSAPID"];

            try
            {
                string userkey = ConfigurationManager.AppSettings["userkey"];
                string uid     = ConfigurationManager.AppSettings["uid"];

                Employer.Employer employer = new Employer.Employer();
                DataTable         dt       = employer.FetchAllRoles();
                dt.TableName = "FetchRoles";
                var roles = (from DataRow dr in dt.Rows
                             where dr["isexternal"].ToString().Trim() != "Y"
                             select new Models.UserRoles()
                {
                    ID = dr["ID"].ToString(),
                    Name = dr["Name"].ToString(),
                    Code = dr["Code"].ToString()
                }).ToList();

                return(Json(new { data = roles }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                LogError logerror = new LogError();
                logerror.ErrorLog("", LoginUser, "", "Admin/GetRoles", "Admin", "GetRoles", "FetchAllRoles Error", ex.Message.ToString(), 0);
                return(Json(new { data = "Error has occured" }, JsonRequestBehavior.AllowGet));
            }
        }
Beispiel #2
0
        public JsonResult GetRequestCategory()
        {
            string LoginUser = (string)Session["LoginSAPID"];

            try
            {
                string userkey = ConfigurationManager.AppSettings["userkey"];
                string uid     = ConfigurationManager.AppSettings["uid"];
                string ROLE_ID = (string)Session["ROLE_ID"];

                Employer.Employer employer = new Employer.Employer();
                DataTable         dt       = employer.FetchRequestCategories(ROLE_ID, userkey, uid);
                dt.TableName = "Fetchrequestcategory";
                dt.Columns.ToString();
                var requestCategory = (from DataRow dr in dt.Rows
                                       select new
                {
                    ID = dr["ID"].ToString(),
                    Descr = dr["Descr"].ToString(),
                    Mail = dr["Mail"].ToString(),
                    Dynamictext = dr["dynamictext"].ToString(),
                    Dynamicurl = dr["dynamicurls"].ToString(),
                    IsAES = dr["IsAES"].ToString()
                }).ToList();

                return(Json(new { data = requestCategory }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                LogError logerror = new LogError();
                logerror.ErrorLog("", LoginUser, "", "Requests/GetRequestCategory", "Requests", "GetRequestCategory", "FetchRequestCategories Error", ex.Message.ToString(), 0);
                return(Json(new { data = "Error has occured" }, JsonRequestBehavior.AllowGet));
            }
        }
        public ActionResult DeactivateUser(string StaffID)
        {
            string userkey   = ConfigurationManager.AppSettings["userkey"];
            string uid       = ConfigurationManager.AppSettings["uid"];
            string LoginUser = (string)Session["LoginSAPID"];

            try
            {
                Employer.Employer employer = new Employer.Employer();
                var updateStatus           = employer.AdministerInternalUser(StaffID, LoginUser, "1", "3", userkey, uid);
                var updateDetails          = updateStatus.Split('~');

                if (updateDetails[0] != "01")
                {
                    TempData["smessage"] = updateDetails[1];
                    return(RedirectToAction("Index"));
                }
                else
                {
                    TempData["message"] = updateDetails[1];
                    return(RedirectToAction("Index"));
                }
            }
            catch (Exception ex)
            {
                LogError logerror = new LogError();
                logerror.ErrorLog("", LoginUser, "", "Admin/UpdateUsers", "Admin", "ActivateUser", "AdministerInternalUser Error", ex.Message.ToString(), 0);
                TempData["error"] = ex.Message.ToString();
                ViewBag.Error     = TempData["error"];
                return(RedirectToAction("Index"));
            }
        }
Beispiel #4
0
        public ActionResult Create(AdminViews views)
        {
            string userkey   = ConfigurationManager.AppSettings["userkey"];
            string uid       = ConfigurationManager.AppSettings["uid"];
            string LoginUser = (string)Session["LoginSAPID"];

            try
            {
                Employer.Employer employer = new Employer.Employer();
                var defineRole             = employer.DefineView(views.MenuName, views.ControllerName, views.ActionName, "INP211", userkey, uid);

                var roleDetails = defineRole.Split('~');

                if (roleDetails[0] != "01")
                {
                    TempData["msg"] = roleDetails[1];
                    return(RedirectToAction("Index"));
                }
                else
                {
                    TempData["error"] = roleDetails[1];
                    return(RedirectToAction("Index"));
                }
            }
            catch (Exception ex)
            {
                LogError logerror = new LogError();
                logerror.ErrorLog("", LoginUser, "", "AdminViews/Create", "AdminViews", "Create", "DefineView Error", ex.Message.ToString(), 0);
                TempData["error"] = ex.Message.ToString();
                ViewBag.Error     = TempData["error"];
                return(View());
            }
        }
        public ActionResult ChangePassword(string WebUserID, string oldpassword, string newpassword)
        {
            string userkey   = ConfigurationManager.AppSettings["userkey"];
            string uid       = ConfigurationManager.AppSettings["uid"];
            string LoginUser = (string)Session["LoginSAPID"];

            string ipaddress   = Request.UserHostAddress;
            string Agent       = Request.UserAgent;
            string BrowserUsed = Request.Browser.Browser;

            try
            {
                Employer.Employer employer = new Employer.Employer();
                var changeStatus           = employer.ChangePassword(WebUserID, BrowserUsed, WebUserID, newpassword, uid, userkey, uid);

                var changeDetails = changeStatus.Split('~');

                if (changeDetails[0] != "4")
                {
                    TempData["error"] = changeDetails[1];
                    return(RedirectToAction("Index"));
                }
                else
                {
                    TempData["error"] = changeDetails[1];
                    return(RedirectToAction("Index"));
                }
            }catch (Exception ex)
            {
                LogError logerror = new LogError();
                logerror.ErrorLog(WebUserID, "", "", "Login/ChangePassword", "Login", "ChangePassword", "ChangePassword Error", ex.Message.ToString(), 0);
                return(View());
            }
        }
        public JsonResult GetMaritalStatusRatio()
        {
            string userkey   = ConfigurationManager.AppSettings["userkey"];
            string uid       = ConfigurationManager.AppSettings["uid"];
            string LoginUser = (string)Session["LoginSAPID"];

            try
            {
                Employer.Employer employer = new Employer.Employer();
                DataTable         dt       = employer.FetchCompanYEmployees("1002", userkey, uid);
                dt.TableName = "ExternalUsers";

                dt.Columns.ToString();
                var requestCategory = (from DataRow dr in dt.Rows
                                       //where dr["eid"].ToString() == "113"
                                       group dr by dr["Marital Status"] into g
                                       select new
                {
                    Mid = g.Key,
                    Count = g.Count()
                }).ToList();

                return(Json(new { data = requestCategory }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                LogError logerror = new LogError();
                logerror.ErrorLog("", LoginUser, "", "Requests/GetRequestCategory", "Requests", "GetRequestCategory", "FetchRequestCategories Error", ex.Message.ToString(), 0);
                return(Json(new { data = "Error has occured" }, JsonRequestBehavior.AllowGet));
            }
        }
Beispiel #7
0
        public ActionResult RoleDetails(string roleId)
        {
            string userkey   = ConfigurationManager.AppSettings["userkey"];
            string uid       = ConfigurationManager.AppSettings["uid"];
            string LoginUser = (string)Session["LoginSAPID"];

            try
            {
                Employer.Employer employer = new Employer.Employer();
                DataTable         dt       = employer.FetchRoleView(roleId, userkey, uid);
                dt.TableName = "FetchRolesView";
                dt.Columns.ToString();

                List <AdminViews> adminViews = (from DataRow dr in dt.Rows
                                                select new AdminViews()
                {
                    ID = dr["ID"].ToString(),
                    MenuID = dr["MenuID"].ToString(),
                    ParentMenuID = dr["ParentMenuID"].ToString(),
                    ParentMenuName = dr["parentmenyname"].ToString(),
                    MenuName = dr["MenuName"].ToString(),
                }).ToList();
                ViewData.Model = adminViews;
                return(View());
            }
            catch (Exception ex)
            {
                LogError logerror = new LogError();
                logerror.ErrorLog("", LoginUser, "", "AdminViews/RoleDetails", "AdminViews", "RoleDetails", "FetchRoleView Error", ex.Message.ToString(), 0);
                TempData["error"] = ex.Message.ToString();
                ViewBag.Error     = TempData["error"];
                return(View());
            }
        }
Beispiel #8
0
        public ActionResult UnMapView(string viewId)
        {
            string userkey   = ConfigurationManager.AppSettings["userkey"];
            string uid       = ConfigurationManager.AppSettings["uid"];
            string LoginUser = (string)Session["LoginSAPID"];

            try
            {
                Employer.Employer employer = new Employer.Employer();
                var unMap       = employer.UnMapRoleView(viewId, LoginUser, userkey, uid);
                var unmapStatus = unMap.Split('~');

                if (unmapStatus[0] != "01")
                {
                    TempData["error"] = unmapStatus[1];
                    ViewBag.Error     = TempData["error"];
                    return(RedirectToAction("MapViewsToRole"));
                }
                else
                {
                    TempData["error"] = unmapStatus[1];
                    ViewBag.Error     = TempData["error"];
                    return(RedirectToAction("MapViewsToRole"));
                }
            }
            catch (Exception ex)
            {
                LogError logerror = new LogError();
                logerror.ErrorLog("", LoginUser, "", "AdminViews/UnMapView", "AdminViews", "UnMapView", "UnMapRoleView Error", ex.Message.ToString(), 0);
                TempData["error"] = ex.Message.ToString();
                ViewBag.Error     = TempData["error"];
                return(View());;
            }
        }
        public ActionResult EditEmployerContact(EmployerContacts contact, String EmployerId)
        {
            string LoginUser = (string)Session["LoginSAPID"];
            string userkey   = ConfigurationManager.AppSettings["userkey"];
            string uid       = ConfigurationManager.AppSettings["uid"];

            try
            {
                Employer.Employer employer = new Employer.Employer();
                var createEmContact        = employer.ModifyExternalUser(contact.EmployerID, "", contact.Email, contact.Fullname, contact.PhoneNo, LoginUser, contact.Role, contact.ID, userkey, uid);
                var createStatus           = createEmContact.Split('~');

                if (createStatus[0] != "01")
                {
                    TempData["Msg"]  = createStatus[1];
                    ViewBag.sMessage = TempData["Msg"];
                    return(RedirectToAction("Index"));
                    //return View();
                }
                else
                {
                    TempData["error"] = createStatus[1];
                    ViewBag.Error     = TempData["error"];
                    return(View());
                }
            }
            catch (Exception ex)
            {
                LogError logerror = new LogError();
                logerror.ErrorLog("", LoginUser, "", "Admin/CreateRole", "Admin", "CreateRole", "CreateRole Error", ex.Message.ToString(), 0);
                TempData["error"] = ex.Message.ToString();
                ViewBag.Error     = TempData["error"];
                return(View());
            }
        }
Beispiel #10
0
        public JsonResult GetInternalUsers()
        {
            string LoginUser = (string)Session["LoginSAPID"];

            try
            {
                string userkey = ConfigurationManager.AppSettings["userkey"];
                string uid     = ConfigurationManager.AppSettings["uid"];

                Employer.Employer employer = new Employer.Employer();
                DataTable         dt       = employer.FetchInternalUsers(userkey, uid);
                dt.TableName = "InternalUsers";
                dt.Columns.ToString();

                var users = (from DataRow dr in dt.Rows
                             select new Models.InternalUsers()
                {
                    ID = dr["ID"].ToString(),
                    FULLNAME = dr["FULLNAME"].ToString(),
                    ROLE_ID = dr["ROLE_ID"].ToString()
                }).ToList();

                return(Json(new { data = users }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                LogError logerror = new LogError();
                logerror.ErrorLog("", LoginUser, "", "Requests/GetInternalUsers", "Requests", "GetInternalUsers", "FetchInternalUsers Error", ex.Message.ToString(), 0);
                return(Json(new { data = "Error has occured" }, JsonRequestBehavior.AllowGet));
            }
        }
Beispiel #11
0
        public ActionResult MapRole(string menuId, string parentId, string roleId)
        {
            string userkey   = ConfigurationManager.AppSettings["userkey"];
            string uid       = ConfigurationManager.AppSettings["uid"];
            string LoginUser = (string)Session["LoginSAPID"];

            try
            {
                Employer.Employer employer = new Employer.Employer();
                var mapResult = employer.MapRoleView(menuId, parentId, roleId, "INP211", userkey, uid);

                var mapDetails = mapResult.Split('~');

                if (mapDetails[0] != "01")
                {
                    TempData["msg"] = mapDetails[1];
                    return(RedirectToAction("EditRole"));
                }
                else
                {
                    TempData["error"] = mapDetails[1];
                    return(RedirectToAction("EditRole"));
                }
            }
            catch (Exception ex)
            {
                LogError logerror = new LogError();
                logerror.ErrorLog("", LoginUser, "", "AdminViews/UnMapView", "AdminViews", "UnMapView", "UnMapRoleView Error", ex.Message.ToString(), 0);
                TempData["error"] = ex.Message.ToString();
                ViewBag.Error     = TempData["error"];
                return(RedirectToAction("EditRole"));
            }
        }
Beispiel #12
0
        public JsonResult GetBatchLists()
        {
            string LoginUser   = (string)Session["LoginSAPID"];
            string userkey     = ConfigurationManager.AppSettings["userkey"];
            string uid         = ConfigurationManager.AppSettings["uid"];
            string EmployerId  = (string)Session["EMPLOYER_ID"];
            string CompanyName = (string)Session["CompanyName"];
            string _access_key = ConfigurationManager.AppSettings["Salt"];

            try
            {
                Employer.Employer employer = new Employer.Employer();

                DataTable dt = employer.FetchStatementEmployerBatch(CompanyName, EmployerId, userkey, uid);
                dt.TableName = "EmployerBatch";
                dt.Columns.ToString();

                var batches = (from DataRow dr in dt.Rows
                               select new
                {
                    ID = CryptoEngine.EncryptString(dr["Category ID"].ToString(), _access_key),
                    BatchName = dr["StmtBatchName"].ToString(),
                    AddressId = CryptoEngine.EncryptString(dr["Address ID"].ToString(), _access_key),
                }).ToList();

                return(Json(new { data = batches }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                LogError logerror = new LogError();
                logerror.ErrorLog("", LoginUser, "", "StatementOptions/GetBatchLists", "StatementOptions", "GetBatchLists", "FetchInternalUsers Error", ex.Message.ToString(), 0);
                return(Json(new { data = "Error has occured" }, JsonRequestBehavior.AllowGet));
            }
        }
Beispiel #13
0
        public ActionResult Batch(Batch batch)
        {
            string LoginUser   = (string)Session["LoginSAPID"];
            string userkey     = ConfigurationManager.AppSettings["userkey"];
            string uid         = ConfigurationManager.AppSettings["uid"];
            string EmployerId  = (string)Session["EMPLOYER_ID"];
            string CompanyName = (string)Session["CompanyName"];

            try
            {
                Employer.Employer employer = new Employer.Employer();

                var batchStatus   = employer.CreateStatementEmployerBatch(batch.BatchName, CompanyName, EmployerId, batch.ContactAddress, batch.ContactAddress1, batch.ContactLGA, batch.ContactState, batch.ContactName, batch.ContactPhone, batch.ContactName2, batch.ContactPhone2, userkey, uid);
                var statusDetails = batchStatus.Split('~');

                if (statusDetails[0] != "01")
                {
                    TempData["bMsg"] = statusDetails[1];
                    return(RedirectToAction("Index"));
                }
                else
                {
                    TempData["bError"] = statusDetails[1];
                    return(RedirectToAction("Index"));
                }
            }
            catch (Exception ex)
            {
                LogError logerror = new LogError();
                logerror.ErrorLog("", LoginUser, "", "StatementOptions/Batch", "StatementOptions", "Batch", "FetchInternalUsers Error", ex.Message.ToString(), 0);
                TempData["bError"] = ex.Message.ToString();
                return(RedirectToAction("Index"));
            }
        }
Beispiel #14
0
        public JsonResult GetAllRoles([ModelBinder(typeof(DataTablesBinder))] IDataTablesRequest requestModel)
        {
            string userkey   = ConfigurationManager.AppSettings["userkey"];
            string uid       = ConfigurationManager.AppSettings["uid"];
            string LoginUser = (string)Session["LoginSAPID"];

            try
            {
                Employer.Employer employer = new Employer.Employer();
                DataTable         dt       = employer.FetchAllRoles();
                dt.TableName = "Roles";

                List <UserRoles> roles = new List <UserRoles>();
                int startRec           = requestModel.Start;
                int pageSize           = requestModel.Length;


                List <UserRoles> roleCount = (from DataRow dr in dt.Rows
                                              select new UserRoles()
                {
                    ID = dr["ID"].ToString()
                }).ToList();

                roles = (from DataRow dr in dt.Rows
                         select new UserRoles()
                {
                    ID = dr["ID"].ToString(),
                    Name = dr["NAME"].ToString(),
                    Code = dr["CODE"].ToString(),
                }).Skip(startRec).Take(pageSize).ToList();

                var totalCount    = roleCount.Count();
                var filteredCount = roleCount.Count();

                var sortedColumns = requestModel.Columns.GetSortedColumns();
                var orderByString = String.Empty;

                foreach (var column in sortedColumns)
                {
                    orderByString += orderByString != String.Empty ? "," : "";
                    orderByString += (column.Data) + (column.SortDirection == Column.OrderDirection.Ascendant ? " asc" : " desc");
                }

                var data = roles.Select(emList => new
                {
                    ID   = emList.ID,
                    Name = emList.Name,
                    Code = emList.Code
                }).ToList();

                return(Json(new DataTablesResponse(requestModel.Draw, data, totalCount, totalCount), JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                LogError logerror = new LogError();
                logerror.ErrorLog("", LoginUser, "", "AdminViewsController/GetAllRoles", "AdminViewsController", "GetAllRoles", "FetchAllRoles Error", ex.Message.ToString(), 0);
                throw new Exception(ex.Message.ToString());
            }
        }
        public ActionResult Details()
        {
            string userkey     = ConfigurationManager.AppSettings["userkey"];
            string uid         = ConfigurationManager.AppSettings["uid"];
            string LoginUser   = (string)Session["LoginSAPID"];
            string _access_key = ConfigurationManager.AppSettings["Salt"];
            string Pin         = this.Request.QueryString[0];

            try
            {
                Util.Util       utility = new Util.Util();
                Crypto.Service1 _crypt  = new Crypto.Service1();
                string          dPin    = _crypt.Decryptfx(Pin, _access_key);

                DataTable dt = utility.Fetchdata(dPin, "", userkey, uid);
                dt.TableName = "CompanyEmployees";

                var EmployeeDetails = (from DataRow dr in dt.Rows
                                       select new CompanyEmployee()
                {
                    Title = dr["Title"].ToString(),
                    FirstName = dr["First Name"].ToString(),
                    LastName = dr["Last Name"].ToString(),
                    MiddleName = dr["Middle Names"].ToString(),
                    PhoneNo = dr["Mobile 1"].ToString(),
                    DateOfBirth = dr["Date Of Birth"].ToString(),
                    DateOfEmployment = dr["Date Of Employment"].ToString(),
                    Email = dr["E-mail"].ToString(),
                    StateOfOrigin = dr["State of Origin"].ToString(),
                    LGA = dr["Local Government Authority"].ToString(),
                    Address = dr["Address"].ToString(),
                    Address2 = dr["Address 2"].ToString(),
                    City = dr["City"].ToString(),
                    Religion = dr["Religion"].ToString(),
                    Nationality = dr["Nationality"].ToString(),
                    Qualification = dr["Qualification"].ToString(),
                    State = dr["State of Posting"].ToString(),
                }).ToList();

                ViewBag.Details = EmployeeDetails;
                return(View());
            }
            catch (Exception ex)
            {
                LogError logerror = new LogError();
                logerror.ErrorLog("", LoginUser, "", "Employee/Details", "Employee", "Details", "Fetchdata Error", ex.Message.ToString(), 0);
                return(RedirectToAction("Index"));
            }
        }
Beispiel #16
0
        public ActionResult EditRole(string Id, string Name)
        {
            string userkey   = ConfigurationManager.AppSettings["userkey"];
            string uid       = ConfigurationManager.AppSettings["uid"];
            string LoginUser = (string)Session["LoginSAPID"];

            try
            {
                Employer.Employer employer = new Employer.Employer();
                DataTable         dt       = employer.FetchViews(userkey, uid);
                dt.TableName = "AdminViews";
                dt.Columns.ToString();


                var adminViews = (from DataRow dr in dt.Rows
                                  select new AdminViews()
                {
                    ID = dr["MenuID"].ToString(),
                    MenuName = dr["MenuName"].ToString(),
                    ControllerName = dr["Controller"].ToString(),
                    ActionName = dr["Action"].ToString(),
                }).ToList();

                ViewData.Model = adminViews;

                ViewBag.ParentId = adminViews;

                return(View());
            }
            catch (Exception ex)
            {
                LogError logerror = new LogError();
                logerror.ErrorLog("", LoginUser, "", "AdminViews/EditRole", "AdminViews", "EditRole", "FetchViews Error", ex.Message.ToString(), 0);
                TempData["error"] = ex.Message.ToString();
                ViewBag.Error     = TempData["error"];
                return(View());
            }
        }
Beispiel #17
0
        public JsonResult GetValidSapId(string SAPID)
        {
            string userkey   = ConfigurationManager.AppSettings["userkey"];
            string uid       = ConfigurationManager.AppSettings["uid"];
            string LoginUser = (string)Session["LoginSAPID"];

            try
            {
                string ipaddress   = Request.UserHostAddress;
                string BrowserUsed = Request.UserAgent;

                Employer.Employer employer = new Employer.Employer();
                var validDetails           = employer.ADAuth(SAPID, BrowserUsed, ipaddress, "", userkey, uid);
                var sapDetails             = validDetails.Split('~');
                return(Json(new { data = sapDetails }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                LogError logerror = new LogError();
                logerror.ErrorLog("", LoginUser, "", "Admin/GetValidSapId", "Admin", "GetValidSapId", "ADAuth Error", ex.Message.ToString(), 0);
                throw new Exception(ex.Message.ToString());
            }
        }
Beispiel #18
0
        public ActionResult CreateRole(UserRoles role)
        {
            string LoginUser = (string)Session["LoginSAPID"];

            try
            {
                string userkey = ConfigurationManager.AppSettings["userkey"];
                string uid     = ConfigurationManager.AppSettings["uid"];

                Employer.Employer employer = new Employer.Employer();

                var createRole = employer.CreateRole(role.Name, LoginUser, userkey, uid);

                var createStatus = createRole.Split('~');
                if (createStatus[0] != "01")
                {
                    TempData["error"] = createStatus[1];
                    ViewBag.Error     = TempData["error"];
                    //return RedirectToAction("Roles");
                    return(View());
                }
                else
                {
                    TempData["error"] = createStatus[1];
                    ViewBag.Error     = TempData["error"];
                    return(View());
                }
            }
            catch (Exception ex)
            {
                LogError logerror = new LogError();
                logerror.ErrorLog("", LoginUser, "", "Admin/CreateRole", "Admin", "CreateRole", "CreateRole Error", ex.Message.ToString(), 0);
                TempData["error"] = ex.Message.ToString();
                ViewBag.Error     = TempData["error"];
                return(View());
            }
        }
Beispiel #19
0
        public ActionResult Create(AdminUsers admin)
        {
            string LoginUser = (string)Session["LoginSAPID"];

            try
            {
                string userkey = ConfigurationManager.AppSettings["userkey"];
                string uid     = ConfigurationManager.AppSettings["uid"];

                Employer.Employer employer = new Employer.Employer();

                var createAdmin = employer.AdministerInternalUser(admin.SAPID, LoginUser, admin.Role, "1", userkey, uid);

                var createStatus = createAdmin.Split('~');
                if (createStatus[0] != "01")
                {
                    TempData["error"] = createStatus[1];
                    ViewBag.Error     = TempData["error"];
                    return(RedirectToAction("Index"));
                }
                else
                {
                    TempData["error"] = createStatus[1];
                    ViewBag.Error     = TempData["error"];
                    return(View());
                }
            }
            catch (Exception ex)
            {
                LogError logerror = new LogError();
                logerror.ErrorLog("", LoginUser, "", "Admin/Create", "Admin", "Create", "AdministerInternalUser Error", ex.Message.ToString(), 0);
                TempData["error"] = ex.Message.ToString();
                ViewBag.Error     = TempData["error"];
                return(View());
            }
        }
Beispiel #20
0
        public JsonResult GetRequests([ModelBinder(typeof(DataTablesBinder))] IDataTablesRequest requestModel, String EmployerId)
        {
            string userkey     = ConfigurationManager.AppSettings["userkey"];
            string uid         = ConfigurationManager.AppSettings["uid"];
            string LoginUser   = (string)Session["LoginSAPID"];
            string _access_key = ConfigurationManager.AppSettings["Salt"];

            string WebUserID   = (string)Session["WebUserID"];
            string EMPLOYER_ID = (string)Session["EMPLOYER_ID"];

            try
            {
                Employer.Employer employer = new Employer.Employer();
                DataTable         dt       = employer.FetchIncidents("6", EMPLOYER_ID, "N/A", userkey, uid);
                dt.TableName = "Requests";
                dt.Columns.ToString();

                List <Requests> requests = new List <Requests>();
                int             startRec = requestModel.Start;
                int             pageSize = requestModel.Length;

                //DateTime dateTime10 = Convert.ToDateTime(loginStatus[0].LastLogin);
                //Session["LastLogin"] = dateTime10.ToString("dd-MMM-yyyy hh:mm");

                List <Requests> requestCount = (from DataRow dr in dt.Rows
                                                select new Requests()
                {
                    RequestID = dr["RequestID"].ToString()
                }).ToList();

                requests = (from DataRow dr in dt.Rows
                            orderby dr["Datecreated"] descending
                            select new Requests()
                {
                    ID = dr["RequestID"].ToString(),
                    RequestID = dr["RequestID"].ToString(),
                    Category = dr["Cat"].ToString(),
                    Comment = dr["Comment"].ToString(),
                    Datecreated = Convert.ToDateTime(dr["Datecreated"]).ToString("dd-MMM-yyyy hh:mm"),
                    CurrentStatus = dr["CurrentStatus"].ToString(),
                    CurrentAssignedToID = dr["CurrentAssignedToID"].ToString(),
                    CurrentAssignedRoleID = dr["CurrentAssignedRoleID"].ToString()
                }).Skip(startRec).Take(pageSize).ToList();

                var totalCount    = requestCount.Count();
                var filteredCount = requests.Count();

                if (requestModel.Search.Value != string.Empty)
                {
                    var value = requestModel.Search.Value.ToLower().Trim();

                    requestCount = (from DataRow dr in dt.Rows
                                    where dr["RequestID"].ToString().ToLower().Contains(value) || dr["Cat"].ToString().ToLower().Contains(value) ||
                                    dr["Datecreated"].ToString().ToLower().Contains(value) || dr["CurrentStatus"].ToString().ToLower().Contains(value)
                                    select new Requests()
                    {
                        RequestID = dr["RequestID"].ToString()
                    }).ToList();

                    requests = (from DataRow dr in dt.Rows
                                orderby dr["Datecreated"] descending
                                where dr["RequestID"].ToString().ToLower().Contains(value) || dr["Cat"].ToString().ToLower().Contains(value) ||
                                Convert.ToDateTime(dr["Datecreated"]).ToString("dd-MMM-yyyy hh:mm").ToLower().Contains(value) ||
                                dr["CurrentStatus"].ToString().ToLower().Contains(value)
                                select new Requests()
                    {
                        RequestID = dr["RequestID"].ToString(),
                        Category = dr["Cat"].ToString(),
                        Comment = dr["Comment"].ToString(),
                        Datecreated = Convert.ToDateTime(dr["Datecreated"]).ToString("dd-MMM-yyyy hh:mm"),
                        CurrentStatus = dr["CurrentStatus"].ToString(),
                        CurrentAssignedToID = dr["CurrentAssignedToID"].ToString(),
                        CurrentAssignedRoleID = dr["CurrentAssignedRoleID"].ToString()
                    }).Skip(startRec).Take(pageSize).ToList();

                    totalCount    = requestCount.Count();
                    filteredCount = requests.Count();
                }

                var sortedColumns = requestModel.Columns.GetSortedColumns();
                var orderByString = String.Empty;

                foreach (var column in sortedColumns)
                {
                    orderByString += orderByString != String.Empty ? "," : "";
                    orderByString += (column.Data) + (column.SortDirection == Column.OrderDirection.Ascendant ? " asc" : " desc");
                }

                var data = requests.Select(emList => new
                {
                    RequestID             = emList.RequestID,
                    Category              = emList.Category,
                    Comment               = emList.Comment,
                    CurrentStatus         = emList.CurrentStatus,
                    Datecreated           = emList.Datecreated,
                    CurrentAssignedToID   = emList.CurrentAssignedToID,
                    CurrentAssignedRoleID = emList.CurrentAssignedRoleID
                }).OrderBy(orderByString == string.Empty ? "ID asc" : orderByString).ToList();

                return(Json(new DataTablesResponse(requestModel.Draw, data, totalCount, totalCount), JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                LogError logerror = new LogError();
                logerror.ErrorLog("", LoginUser, "", "Requests/GetRequests", "Requests", "GetRequests", "FetchIncidents Error", ex.Message.ToString(), 0);
                return(Json(new { data = "Error has occured" }, JsonRequestBehavior.AllowGet));
            }
        }
Beispiel #21
0
        public JsonResult GetAdminViews([ModelBinder(typeof(DataTablesBinder))] IDataTablesRequest requestModel)
        {
            string userkey   = ConfigurationManager.AppSettings["userkey"];
            string uid       = ConfigurationManager.AppSettings["uid"];
            string LoginUser = (string)Session["LoginSAPID"];

            try
            {
                Employer.Employer employer = new Employer.Employer();
                DataTable         dt       = employer.FetchViews(userkey, uid);
                dt.TableName = "AdminViews";
                dt.Columns.ToString();
                List <AdminViews> adminViews = new List <AdminViews>();
                int startRec = requestModel.Start;
                int pageSize = requestModel.Length;


                List <AdminViews> viewsCount = (from DataRow dr in dt.Rows
                                                select new AdminViews()
                {
                    MenuName = dr["MenuName"].ToString()
                }).ToList();

                adminViews = (from DataRow dr in dt.Rows
                              select new AdminViews()
                {
                    MenuName = dr["MenuName"].ToString(),
                    ControllerName = dr["Controller"].ToString(),
                    ActionName = dr["Action"].ToString(),
                }).Skip(startRec).Take(pageSize).ToList();

                var totalCount    = viewsCount.Count();
                var filteredCount = adminViews.Count();

                /*if (requestModel.Search.Value != string.Empty)
                 * {
                 *  var value = requestModel.Search.Value.Trim();
                 *
                 *  employeeCount = (from DataRow dr in dt.Rows
                 *                   where dr["P_I_N"].ToString().ToString().Contains(value) || dr["First Name"].ToString().Contains(value)
                 || dr["Last Name"].ToString().Contains(value) || dr["Phone No"].ToString().Contains(value)
                 || dr["E-mail"].ToString().Contains(value)
                 ||                  select new CompanyEmployee()
                 ||                  {
                 ||                      PIN = dr["P_I_N"].ToString()
                 ||                  }).ToList();
                 ||
                 || companyEmployee = (from DataRow dr in dt.Rows
                 ||                    where dr["P_I_N"].ToString().ToString().Contains(value) || dr["First Name"].ToString().Contains(value)
                 || dr["Last Name"].ToString().Contains(value) || dr["Phone No"].ToString().Contains(value)
                 || dr["E-mail"].ToString().Contains(value)
                 ||                    select new CompanyEmployee()
                 ||                    {
                 ||                        PIN = dr["P_I_N"].ToString(),
                 ||                        FirstName = dr["First Name"].ToString(),
                 ||                        LastName = dr["Last Name"].ToString(),
                 ||                        MiddleName = dr["Middle Names"].ToString(),
                 ||                        PhoneNo = dr["Mobile 1"].ToString(),
                 ||                        DateOfBirth = dr["Date Of Birth"].ToString(),
                 ||                        DateOfEmployment = dr["Date Of Employment"].ToString(),
                 ||                        Email = dr["E-mail"].ToString(),
                 ||                    }).Skip(startRec).Take(pageSize).ToList();
                 ||
                 || totalCount = employeeCount.Count();
                 || filteredCount = companyEmployee.Count();
                 ||}*/

                var sortedColumns = requestModel.Columns.GetSortedColumns();
                var orderByString = String.Empty;

                foreach (var column in sortedColumns)
                {
                    orderByString += orderByString != String.Empty ? "," : "";
                    orderByString += (column.Data) + (column.SortDirection == Column.OrderDirection.Ascendant ? " asc" : " desc");
                }

                var data = adminViews.Select(emList => new
                {
                    MenuName       = emList.MenuName,
                    ControllerName = emList.ControllerName,
                    ActionName     = emList.ActionName
                }).ToList();

                return(Json(new DataTablesResponse(requestModel.Draw, data, totalCount, totalCount), JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                LogError logerror = new LogError();
                logerror.ErrorLog("", LoginUser, "", "AdminViewsController/GetAdminViews", "AdminViewsController", "GetAdminViews", "FetchViews Error", ex.Message.ToString(), 0);
                throw new Exception(ex.Message.ToString());
            }
        }
Beispiel #22
0
        public ActionResult Index(string ReportType, string ReportFormat, string startdate, string enddate)
        {
            string userkey     = ConfigurationManager.AppSettings["userkey"];
            string uid         = ConfigurationManager.AppSettings["uid"];
            string LoginUser   = (string)Session["LoginSAPID"];
            string EMPLOYER_ID = (string)Session["EMPLOYER_ID"];
            string CompanyName = (string)Session["CompanyName"];

            try
            {
                if (ReportType == "1")
                {
                    if (ReportFormat == "PDF")
                    {
                        Employer.Employer employer = new Employer.Employer();
                        var report = employer.Report_CFI_Status_Report_By_Employer(EMPLOYER_ID, "PDF", userkey, uid, uid);

                        //var report = employer.Report_RSA_Details_by_employer(CompanyName, "PDF", userkey, uid, uid);
                        if (report != null)
                        {
                            string stmt_name = EMPLOYER_ID.ToString().Trim() + "_" + DateTime.Today.Day.ToString() + DateTime.Today.Month.ToString() + DateTime.Today.Year.ToString() + DateTime.Today.Second.ToString() + DateTime.Today.Millisecond.ToString() + DateTime.UtcNow.Ticks + EMPLOYER_ID;
                            string pth       = stmt_name + ".pdf";
                            Response.AppendCookie(new HttpCookie("fileDownloadToken", "Report"));
                            //FileStream stream = System.IO.File.Create(pth, report.Length);
                            //stream.Write(report, 0, report.Length);
                            //stream.Close();
                            return(File(report, "application/pdf", pth));
                        }
                        else
                        {
                            TempData["error"] = "Report not found";
                            return(View());
                        }
                    }
                    else if (ReportFormat == "CSV")
                    {
                        Employer.Employer employer = new Employer.Employer();
                        var report = employer.Report_CFI_Status_Report_By_Employer(EMPLOYER_ID, "csv", userkey, uid, uid);

                        if (report != null)
                        {
                            string stmt_name = EMPLOYER_ID.ToString().Trim() + "_" + DateTime.Today.Day.ToString() + DateTime.Today.Month.ToString() + DateTime.Today.Year.ToString() + DateTime.Today.Second.ToString() + DateTime.Today.Millisecond.ToString() + DateTime.UtcNow.Ticks + EMPLOYER_ID;
                            string pth       = stmt_name + ".csv";
                            Response.AppendCookie(new HttpCookie("fileDownloadToken", "Report"));
                            //FileStream stream = System.IO.File.Create(pth, report.Length);
                            //stream.Write(report, 0, report.Length);
                            //stream.Close();
                            return(File(report, "text/csv", pth));
                        }
                        else
                        {
                            TempData["error"] = "Report not found";
                            return(View());
                        }
                    }
                    else
                    {
                        TempData["error"] = "File type not allowed";
                        return(View());
                    }
                }
                else if (ReportType == "2")
                {
                    Employer.Employer employer = new Employer.Employer();

                    var report = employer.Report_Pencom_Employer_Code(EMPLOYER_ID, "PDF", userkey, uid, uid);
                    if (report != null)
                    {
                        string stmt_name = EMPLOYER_ID.ToString().Trim() + "_" + DateTime.Today.Day.ToString() + DateTime.Today.Month.ToString() + DateTime.Today.Year.ToString() + DateTime.Today.Second.ToString() + DateTime.Today.Millisecond.ToString() + DateTime.UtcNow.Ticks + EMPLOYER_ID;
                        string pth       = stmt_name + ".pdf";
                        //FileStream stream = System.IO.File.Create(pth, report.Length);
                        //stream.Write(report, 0, report.Length);
                        //stream.Close();
                        return(File(report, "application/pdf", pth));
                    }
                    else
                    {
                        TempData["error"] = "Report cannot be generated at the moment. Kindly contact System Admininistrator.";
                        return(View());
                    }
                }
                else if (ReportType == "3")
                {
                    if (ReportFormat == "PDF")
                    {
                        Employer.Employer employer = new Employer.Employer();

                        var report = employer.Report_RSA_Details_by_employer(CompanyName, "PDF", userkey, uid, uid);
                        if (report != null)
                        {
                            string stmt_name = EMPLOYER_ID.ToString().Trim() + "_" + DateTime.Today.Day.ToString() + DateTime.Today.Month.ToString() + DateTime.Today.Year.ToString() + DateTime.Today.Second.ToString() + DateTime.Today.Millisecond.ToString() + DateTime.UtcNow.Ticks + EMPLOYER_ID;
                            string pth       = stmt_name + ".pdf";
                            //FileStream stream = System.IO.File.Create(pth, report.Length);
                            //stream.Write(report, 0, report.Length);
                            //stream.Close();
                            return(File(report, "application/pdf", pth));
                        }
                        else
                        {
                            TempData["error"] = "Report not found";
                            return(View());
                        }
                    }
                    else if (ReportFormat == "CSV")
                    {
                        Employer.Employer employer = new Employer.Employer();
                        var report = employer.Report_RSA_Details_by_employer(CompanyName, "csv", userkey, uid, uid);

                        if (report != null)
                        {
                            string stmt_name = EMPLOYER_ID.ToString().Trim() + "_" + DateTime.Today.Day.ToString() + DateTime.Today.Month.ToString() + DateTime.Today.Year.ToString() + DateTime.Today.Second.ToString() + DateTime.Today.Millisecond.ToString() + DateTime.UtcNow.Ticks + EMPLOYER_ID;
                            string pth       = stmt_name + ".csv";
                            //FileStream stream = System.IO.File.Create(pth, report.Length);
                            //stream.Write(report, 0, report.Length);
                            //stream.Close();
                            return(File(report, "text/csv", pth));
                        }
                        else
                        {
                            TempData["error"] = "Report not found";
                            return(View());
                        }
                    }
                    else
                    {
                        TempData["error"] = "File type not allowed";
                        return(View());
                    }
                }
                else if (ReportType == "4")
                {
                    if (ReportFormat == "PDF")
                    {
                        Employer.Employer employer = new Employer.Employer();

                        var report = employer.Report_RSA_Unfunded(CompanyName, startdate, enddate, "PDF", userkey, uid, uid);
                        if (report != null)
                        {
                            string stmt_name = EMPLOYER_ID.ToString().Trim() + "_" + DateTime.Today.Day.ToString() + DateTime.Today.Month.ToString() + DateTime.Today.Year.ToString() + DateTime.Today.Second.ToString() + DateTime.Today.Millisecond.ToString() + DateTime.UtcNow.Ticks + EMPLOYER_ID;
                            string pth       = stmt_name + ".pdf";
                            //FileStream stream = System.IO.File.Create(pth, report.Length);
                            //stream.Write(report, 0, report.Length);
                            //stream.Close();
                            return(File(report, "application/pdf", pth));
                        }
                        else
                        {
                            TempData["error"] = "Report not found";
                            return(View());
                        }
                    }
                    else if (ReportFormat == "CSV")
                    {
                        Employer.Employer employer = new Employer.Employer();
                        var report = employer.Report_RSA_Unfunded(CompanyName, startdate, enddate, "csv", userkey, uid, uid);

                        if (report != null)
                        {
                            string stmt_name = EMPLOYER_ID.ToString().Trim() + "_" + DateTime.Today.Day.ToString() + DateTime.Today.Month.ToString() + DateTime.Today.Year.ToString() + DateTime.Today.Second.ToString() + DateTime.Today.Millisecond.ToString() + DateTime.UtcNow.Ticks + EMPLOYER_ID;
                            string pth       = stmt_name + ".csv";
                            //FileStream stream = System.IO.File.Create(pth, report.Length);
                            //stream.Write(report, 0, report.Length);
                            //stream.Close();
                            return(File(report, "text/csv", pth));
                        }
                        else
                        {
                            TempData["error"] = "Report not found";
                            return(View());
                        }
                    }
                    else
                    {
                        TempData["error"] = "File type not allowed";
                        return(View());
                    }
                }
                else if (ReportType == "5")
                {
                    if (ReportFormat == "PDF")
                    {
                        Employer.Employer employer = new Employer.Employer();

                        var report = employer.Report_RSA_Unfunded(CompanyName, startdate, enddate, "PDF", userkey, uid, uid);

                        if (report != null)
                        {
                            string stmt_name = EMPLOYER_ID.ToString().Trim() + "_" + DateTime.Today.Day.ToString() + DateTime.Today.Month.ToString() + DateTime.Today.Year.ToString() + DateTime.Today.Second.ToString() + DateTime.Today.Millisecond.ToString() + DateTime.UtcNow.Ticks + EMPLOYER_ID;
                            string pth       = stmt_name + ".pdf";
                            //FileStream stream = System.IO.File.Create(pth, report.Length);
                            //stream.Write(report, 0, report.Length);
                            //stream.Close();
                            return(File(report, "application/pdf", pth));
                        }
                        else
                        {
                            TempData["error"] = "Report not found";
                            return(View());
                        }
                    }
                    else if (ReportFormat == "CSV")
                    {
                        Employer.Employer employer = new Employer.Employer();
                        var report = employer.Report_RSA_Unfunded(CompanyName, startdate, enddate, "csv", userkey, uid, uid);

                        if (report != null)
                        {
                            string stmt_name = EMPLOYER_ID.ToString().Trim() + "_" + DateTime.Today.Day.ToString() + DateTime.Today.Month.ToString() + DateTime.Today.Year.ToString() + DateTime.Today.Second.ToString() + DateTime.Today.Millisecond.ToString() + DateTime.UtcNow.Ticks + EMPLOYER_ID;
                            string pth       = stmt_name + ".csv";
                            //FileStream stream = System.IO.File.Create(pth, report.Length);
                            //stream.Write(report, 0, report.Length);
                            //stream.Close();
                            return(File(report, "text/csv", pth));
                        }
                        else
                        {
                            TempData["error"] = "Report not found";
                            return(View());
                        }
                    }
                    else
                    {
                        TempData["error"] = "File type not allowed";
                        return(View());
                    }
                }
                else
                {
                    TempData["error"] = "ReportType not selected";
                    return(View());
                }
            } catch (Exception ex)
            {
                LogError logerror = new LogError();
                logerror.ErrorLog("", LoginUser, "", "Reports/Index", "Reports", "Index", "Reports Error", ex.Message.ToString(), 0);
                TempData["error"] = ex.Message.ToString();
                return(View());
            }
        }
Beispiel #23
0
        public ActionResult UpdateRequest(string requestId, string statusUpdate, string internalUser, string externalUser, string custodianUser, string Comment, string convertedFile, string convertedFile1, string convertedFile2)
        {
            string UploadStatus  = "";
            string UploadStatus1 = "";
            string UploadStatus2 = "";
            string assignedToId  = "";
            string roleId        = "";
            //convertedFile = "";
            //convertedFile1 = "";
            //convertedFile2 = "";

            string ipaddress   = Request.UserHostAddress;
            string Agent       = Request.UserAgent;
            string BrowserUsed = Request.Browser.Browser;
            string SessionID   = HttpContext.Session.SessionID;

            string userkey = ConfigurationManager.AppSettings["userkey"];
            string uid     = ConfigurationManager.AppSettings["uid"];

            string LoginUser  = (string)Session["LoginSAPID"];
            string EmployerId = (string)Session["EMPLOYER_ID"];
            string WebUserID  = (string)Session["WebUserID"];
            string RoleID     = (string)Session["ROLE_ID"];

            try
            {
                Employer.Employer employer = new Employer.Employer();

                if (internalUser != "")
                {
                    assignedToId = internalUser;
                    roleId       = "2";
                }
                else if (externalUser != "")
                {
                    assignedToId = externalUser;
                    roleId       = "3";
                }
                else if (custodianUser != "")
                {
                    assignedToId = externalUser;
                    roleId       = "4";
                }
                string requestStatus;
                if (statusUpdate == "Assigned")
                {
                    requestStatus = employer.AssignRequest(requestId, Comment, WebUserID, "2", roleId, assignedToId, statusUpdate, userkey, uid);
                }
                else
                {
                    requestStatus = employer.AssignRequest(requestId, Comment, WebUserID, "2", roleId, WebUserID, statusUpdate, userkey, uid);
                }
                //var requestStatus = employer.CreateRequest(WebUserID, "3", requestCategory, "Initiated", Comment, userkey, uid);
                var requestDetails = requestStatus.Split('~');

                if (requestDetails[0] != "01")
                {
                    var file = Request.Files;

                    if (file[0].ContentLength > 0)
                    {
                        string _FileName = file[0].FileName;
                        string Docext    = Path.GetExtension(file[0].FileName);
                        string Doc       = convertedFile;
                        UploadStatus = employer.LogRequestDoc(requestId, requestDetails[1], Doc, Docext, _FileName, "Y", userkey, uid);
                        var uploadDetails = UploadStatus.Split('~');
                    }
                    if (file[1].ContentLength > 0)
                    {
                        string _FileName1 = file[1].FileName;
                        string Docext1    = Path.GetExtension(file[1].FileName);
                        string Doc1       = convertedFile1;
                        UploadStatus1 = employer.LogRequestDoc(requestId, requestDetails[1], Doc1, Docext1, _FileName1, "Y", userkey, uid);
                        //var uploadDetails1 = UploadStatus1.Split('~');
                    }
                    if (file[2].ContentLength > 0)
                    {
                        string _FileName2 = file[2].FileName;
                        string Docext2    = Path.GetExtension(file[2].FileName);
                        string Doc2       = convertedFile2;
                        UploadStatus2 = employer.LogRequestDoc(requestId, requestDetails[1], Doc2, Docext2, _FileName2, "Y", userkey, uid);
                        //uploadDetails2 = UploadStatus2.Split('~');
                    }

                    if (UploadStatus == "00~Your documents have been logged successfully" || UploadStatus1 == "00~Your documents have been logged successfully" || UploadStatus2 == "00~Your documents have been logged successfully")
                    {
                        employer.NotifyIncident(requestDetails[1], userkey, uid);
                        string status        = "00~Your documents have been logged successfully";
                        var    statusDetails = status.Split('~');
                        TempData["error"] = "Your request and " + statusDetails[1];
                        //employer
                        return(RedirectToAction("Index"));
                    }
                    else
                    {
                    }


                    TempData["msg"] = requestDetails[2];
                    return(RedirectToAction("Index"));
                }
                else
                {
                    TempData["error"] = requestDetails[2];
                    return(RedirectToAction("Index"));
                }
            }
            catch (Exception ex)
            {
                LogError logerror = new LogError();
                logerror.ErrorLog("", LoginUser, "", "Requests/UpdateRequest", "Requests", "UpdateRequest", "AssignRequest Error", ex.InnerException.Message.ToString(), 0);
                TempData["error"] = "An error processing complaints";
                return(View());
            }
        }
Beispiel #24
0
        public ActionResult Index(Users users, string ReturnUrl)
        {
            string LoginType;

            string ipaddress   = Request.UserHostAddress;
            string Agent       = Request.UserAgent;
            string BrowserUsed = Request.Browser.Browser;
            string SessionID   = HttpContext.Session.SessionID;

            string userkey = ConfigurationManager.AppSettings["userkey"];
            string uid     = ConfigurationManager.AppSettings["uid"];

            try
            {
                List <LoginStatus> loginStatus;

                Employer.Employer employer = new Employer.Employer();

                if ((users.Username.Trim().Length >= 5) && (users.Username.Trim().Contains("@") == true) && (users.Username.Trim().Contains(".") == true))
                {
                    LoginType = "2";
                    DataTable dt = employer.ExternalLogin(users.Username, LoginType, users.Password, BrowserUsed, SessionID, Agent, ipaddress, userkey, uid);
                    dt.TableName = "ReturnedVal";

                    var response = dt.Columns.Count.ToString();

                    if (response == "2")
                    {
                        var loginError = (from DataRow dr in dt.Rows
                                          select new LoginStatus()
                        {
                            ErrorMessage = dr["ErrorMessage"].ToString(),
                            LoginStat = dr["LoginStat"].ToString(),
                        }).ToList();

                        TempData["error"] = loginError[0].ErrorMessage;
                        return(View());
                    }

                    loginStatus = (from DataRow dr in dt.Rows
                                   select new LoginStatus()
                    {
                        ErrorMessage = dr["ErrorMessage"].ToString(),
                        LoginStat = dr["LoginStat"].ToString(),
                        WebUserID = dr["WebUserID"].ToString(),
                        EMPLOYER_ID = dr["EMPLOYER_ID"].ToString(),
                        EnforceChange = dr["EnforceChange"].ToString(),
                        CUSTODIAN_ID = dr["CUSTODIAN_ID"].ToString(),
                        LastLogin = dr["LastLogin"].ToString(),
                        email = dr["email"].ToString(),
                        BrowserUsed = dr["BrowserUsed"].ToString(),
                        ROLE_ID = dr["ROLE_ID"].ToString(),
                        FULLNAME = dr["FULLNAME"].ToString(),
                    }).ToList();

                    if (loginStatus[0].EnforceChange == "Y")
                    {
                        ViewBag.Email        = loginStatus[0].email;
                        Session["WebUserID"] = loginStatus[0].WebUserID;
                        Session["ROLE_ID"]   = loginStatus[0].ROLE_ID;
                        return(RedirectToAction("ChangePassword"));
                    }
                    else if (loginStatus[0].LoginStat == "False")
                    {
                        TempData["error"] = loginStatus[0].ErrorMessage;
                        return(View());
                    }
                    else if (loginStatus[0].ROLE_ID == "3")
                    {
                        FormsAuthentication.SetAuthCookie(loginStatus[0].FULLNAME, false);
                        Session["LoginSAPID"] = users.Username;
                        DateTime dateTime10 = Convert.ToDateTime(loginStatus[0].LastLogin);
                        Session["LastLogin"]   = dateTime10.ToString("dd-MMM-yyyy hh:mm");
                        Session["EMPLOYER_ID"] = loginStatus[0].EMPLOYER_ID;
                        Session["WebUserID"]   = loginStatus[0].WebUserID;
                        Session["ROLE_ID"]     = loginStatus[0].ROLE_ID;

                        DataTable dts = employer.FetchCompanYEmployees(loginStatus[0].EMPLOYER_ID, userkey, uid);
                        dts.TableName = "CompanyEmployees";
                        var companyEmployee = (from DataRow dr in dts.Rows
                                               select new
                        {
                            Coyname = dr["Coyname"].ToString()
                        }).ToList();

                        Session["CompanyName"] = companyEmployee[0].Coyname;

                        DataTable dtz = employer.FetchEmployerContact(loginStatus[0].EMPLOYER_ID);
                        dtz.TableName = "EmpoyerContact";
                        dtz.Columns.ToString();

                        var EmpoyerContact = (from DataRow dr in dtz.Rows
                                              select new
                        {
                            Email = dr["Email"].ToString(),
                            Address = dr["Address"].ToString(),
                            MobilePhone = dr["Mobile Phone"].ToString(),
                            Name = dr["Name"].ToString()
                        }).ToList();

                        Session["EmpoyerContactName"]        = EmpoyerContact[0].Name;
                        Session["EmpoyerContactEmail"]       = EmpoyerContact[0].Email;
                        Session["EmpoyerContactAddress"]     = EmpoyerContact[0].Address;
                        Session["EmpoyerContactMobilePhone"] = EmpoyerContact[0].MobilePhone;

                        if (Url.IsLocalUrl(ReturnUrl) && ReturnUrl.Length > 1 && ReturnUrl.StartsWith("/") && !ReturnUrl.StartsWith("//") && !ReturnUrl.StartsWith("/\\"))
                        {
                            return(Redirect(ReturnUrl));
                        }
                        else
                        {
                            return(RedirectToAction("Index", "Home"));
                        }
                    }
                    else if (loginStatus[0].ROLE_ID == "4")
                    {
                        FormsAuthentication.SetAuthCookie(loginStatus[0].FULLNAME, false);
                        Session["LoginSAPID"] = users.Username;
                        DateTime dateTime10 = Convert.ToDateTime(loginStatus[0].LastLogin);
                        Session["LastLogin"]    = dateTime10.ToString("dd-MMM-yyyy hh:mm");
                        Session["CUSTODIAN_ID"] = loginStatus[0].CUSTODIAN_ID;
                        Session["WebUserID"]    = loginStatus[0].WebUserID;
                        Session["ROLE_ID"]      = loginStatus[0].ROLE_ID;

                        DataTable dts = employer.FetchCompanYEmployees(loginStatus[0].EMPLOYER_ID, userkey, uid);
                        dts.TableName = "CompanyEmployees";
                        var companyEmployee = (from DataRow dr in dts.Rows
                                               select new
                        {
                            Coyname = dr["Coyname"].ToString()
                        }).ToList();
                        Session["CompanyName"] = companyEmployee[0].Coyname;

                        if (Url.IsLocalUrl(ReturnUrl) && ReturnUrl.Length > 1 && ReturnUrl.StartsWith("/") && !ReturnUrl.StartsWith("//") && !ReturnUrl.StartsWith("/\\"))
                        {
                            return(Redirect(ReturnUrl));
                        }
                        else
                        {
                            return(RedirectToAction("Index", "Employee"));
                        }
                    }
                    else if (loginStatus[0].ROLE_ID == "7")
                    {
                        FormsAuthentication.SetAuthCookie(loginStatus[0].FULLNAME, false);
                        Session["LoginSAPID"] = users.Username;
                        DateTime dateTime10 = Convert.ToDateTime(loginStatus[0].LastLogin);
                        Session["LastLogin"]   = dateTime10.ToString("dd-MMM-yyyy hh:mm");
                        Session["EMPLOYER_ID"] = loginStatus[0].EMPLOYER_ID;
                        Session["WebUserID"]   = loginStatus[0].WebUserID;
                        Session["ROLE_ID"]     = loginStatus[0].ROLE_ID;

                        DataTable dts = employer.FetchCompanYEmployees(loginStatus[0].EMPLOYER_ID, userkey, uid);
                        dts.TableName = "CompanyEmployees";
                        var companyEmployee = (from DataRow dr in dts.Rows
                                               select new
                        {
                            Coyname = dr["Coyname"].ToString()
                        }).ToList();
                        Session["CompanyName"] = companyEmployee[0].Coyname;

                        DataTable dtz = employer.FetchEmployerContact(loginStatus[0].EMPLOYER_ID);
                        dtz.TableName = "EmpoyerContact";
                        dtz.Columns.ToString();

                        var EmpoyerContact = (from DataRow dr in dtz.Rows
                                              select new
                        {
                            Email = dr["Email"].ToString(),
                            Address = dr["Address"].ToString(),
                            MobilePhone = dr["Mobile Phone"].ToString(),
                            Name = dr["Name"].ToString()
                        }).ToList();

                        Session["EmpoyerContactName"]        = EmpoyerContact[0].Name;
                        Session["EmpoyerContactEmail"]       = EmpoyerContact[0].Email;
                        Session["EmpoyerContactAddress"]     = EmpoyerContact[0].Address;
                        Session["EmpoyerContactMobilePhone"] = EmpoyerContact[0].MobilePhone;

                        if (Url.IsLocalUrl(ReturnUrl) && ReturnUrl.Length > 1 && ReturnUrl.StartsWith("/") && !ReturnUrl.StartsWith("//") && !ReturnUrl.StartsWith("/\\"))
                        {
                            return(Redirect(ReturnUrl));
                        }
                        else
                        {
                            return(RedirectToAction("Index", "Home"));
                        }
                    }
                }
                else if ((users.Username.Trim().Length >= 10) && ((users.Username.Trim().All(char.IsDigit)) == true))
                {
                    LoginType = "1";
                    DataTable dt = employer.ExternalLogin(users.Username, LoginType, users.Password, BrowserUsed, SessionID, Agent, ipaddress, userkey, uid);
                    dt.TableName = "ReturnedVal";
                    var response = dt.Columns.Count.ToString();

                    if (response == "2")
                    {
                        var loginError = (from DataRow dr in dt.Rows
                                          select new LoginStatus()
                        {
                            ErrorMessage = dr["ErrorMessage"].ToString(),
                            LoginStat = dr["LoginStat"].ToString(),
                        }).ToList();

                        TempData["error"] = loginError[0].ErrorMessage;
                        return(View());
                    }

                    loginStatus = (from DataRow dr in dt.Rows
                                   select new LoginStatus()
                    {
                        ErrorMessage = dr["ErrorMessage"].ToString(),
                        LoginStat = dr["LoginStat"].ToString(),
                        WebUserID = dr["WebUserID"].ToString(),
                        EMPLOYER_ID = dr["EMPLOYER_ID"].ToString(),
                        EnforceChange = dr["EnforceChange"].ToString(),
                        CUSTODIAN_ID = dr["CUSTODIAN_ID"].ToString(),
                        LastLogin = dr["LastLogin"].ToString(),
                        email = dr["email"].ToString(),
                        BrowserUsed = dr["BrowserUsed"].ToString(),
                        ROLE_ID = dr["ROLE_ID"].ToString(),
                        FULLNAME = dr["FULLNAME"].ToString()
                    }).ToList();

                    if (loginStatus[0].EnforceChange == "Y")
                    {
                        ViewBag.Email        = loginStatus[0].email;
                        Session["WebUserID"] = loginStatus[0].WebUserID;
                        return(RedirectToAction("ChangePassword"));
                    }
                    else if (loginStatus[0].LoginStat == "False")
                    {
                        ViewBag.Email = loginStatus[0].email;
                        return(View());
                    }
                    else if (loginStatus[0].LoginStat == "False")
                    {
                        TempData["error"] = loginStatus[0].ErrorMessage;
                        return(View());
                    }
                    else if (loginStatus[0].ROLE_ID == "3")
                    {
                        FormsAuthentication.SetAuthCookie(loginStatus[0].FULLNAME, false);
                        Session["LoginSAPID"] = users.Username;
                        DateTime dateTime10 = Convert.ToDateTime(loginStatus[0].LastLogin);
                        Session["LastLogin"]   = dateTime10.ToString("dd-MMM-yyyy hh:mm");
                        Session["EMPLOYER_ID"] = loginStatus[0].EMPLOYER_ID;
                        Session["WebUserID"]   = loginStatus[0].WebUserID;
                        Session["ROLE_ID"]     = loginStatus[0].ROLE_ID;

                        DataTable dts = employer.FetchCompanYEmployees(loginStatus[0].EMPLOYER_ID, userkey, uid);
                        dts.TableName = "CompanyEmployees";
                        var companyEmployee = (from DataRow dr in dts.Rows
                                               select new
                        {
                            Coyname = dr["Coyname"].ToString()
                        }).ToList();
                        Session["CompanyName"] = companyEmployee[0].Coyname;

                        DataTable dtz = employer.FetchEmployerContact(loginStatus[0].EMPLOYER_ID);
                        dtz.TableName = "EmpoyerContact";
                        dtz.Columns.ToString();

                        var EmpoyerContact = (from DataRow dr in dtz.Rows
                                              select new
                        {
                            Email = dr["Email"].ToString(),
                            Address = dr["Address"].ToString(),
                            MobilePhone = dr["Mobile Phone"].ToString(),
                            Name = dr["Name"].ToString()
                        }).ToList();

                        Session["EmpoyerContactName"]        = EmpoyerContact[0].Name;
                        Session["EmpoyerContactEmail"]       = EmpoyerContact[0].Email;
                        Session["EmpoyerContactAddress"]     = EmpoyerContact[0].Address;
                        Session["EmpoyerContactMobilePhone"] = EmpoyerContact[0].MobilePhone;

                        if (Url.IsLocalUrl(ReturnUrl) && ReturnUrl.Length > 1 && ReturnUrl.StartsWith("/") && !ReturnUrl.StartsWith("//") && !ReturnUrl.StartsWith("/\\"))
                        {
                            return(Redirect(ReturnUrl));
                        }
                        else
                        {
                            return(RedirectToAction("Index", "Home"));
                        }
                    }
                    else if (loginStatus[0].ROLE_ID == "4")
                    {
                        FormsAuthentication.SetAuthCookie(loginStatus[0].FULLNAME, false);
                        Session["LoginSAPID"] = users.Username;
                        DateTime dateTime10 = Convert.ToDateTime(loginStatus[0].LastLogin);
                        Session["LastLogin"]    = dateTime10.ToString("dd-MMM-yyyy hh:mm");
                        Session["CUSTODIAN_ID"] = loginStatus[0].CUSTODIAN_ID;
                        Session["WebUserID"]    = loginStatus[0].WebUserID;
                        Session["ROLE_ID"]      = loginStatus[0].ROLE_ID;

                        DataTable dts = employer.FetchCompanYEmployees(loginStatus[0].EMPLOYER_ID, userkey, uid);
                        dts.TableName = "CompanyEmployees";
                        var companyEmployee = (from DataRow dr in dts.Rows
                                               select new
                        {
                            Coyname = dr["Coyname"].ToString()
                        }).ToList();
                        Session["CompanyName"] = companyEmployee[0].Coyname;

                        if (Url.IsLocalUrl(ReturnUrl) && ReturnUrl.Length > 1 && ReturnUrl.StartsWith("/") && !ReturnUrl.StartsWith("//") && !ReturnUrl.StartsWith("/\\"))
                        {
                            return(Redirect(ReturnUrl));
                        }
                        else
                        {
                            return(RedirectToAction("Index", "Employee"));
                        }
                    }
                    else if (loginStatus[0].ROLE_ID == "7")
                    {
                        FormsAuthentication.SetAuthCookie(loginStatus[0].FULLNAME, false);
                        Session["LoginSAPID"] = users.Username;
                        DateTime dateTime10 = Convert.ToDateTime(loginStatus[0].LastLogin);
                        Session["LastLogin"]   = dateTime10.ToString("dd-MMM-yyyy hh:mm");
                        Session["EMPLOYER_ID"] = loginStatus[0].EMPLOYER_ID;
                        Session["WebUserID"]   = loginStatus[0].WebUserID;
                        Session["ROLE_ID"]     = loginStatus[0].ROLE_ID;

                        DataTable dts = employer.FetchCompanYEmployees(loginStatus[0].EMPLOYER_ID, userkey, uid);
                        dts.TableName = "CompanyEmployees";
                        var companyEmployee = (from DataRow dr in dts.Rows
                                               select new
                        {
                            Coyname = dr["Coyname"].ToString()
                        }).ToList();
                        Session["CompanyName"] = companyEmployee[0].Coyname;

                        DataTable dtz = employer.FetchEmployerContact(loginStatus[0].EMPLOYER_ID);
                        dtz.TableName = "EmpoyerContact";
                        dtz.Columns.ToString();

                        var EmpoyerContact = (from DataRow dr in dtz.Rows
                                              select new
                        {
                            Email = dr["Email"].ToString(),
                            Address = dr["Address"].ToString(),
                            MobilePhone = dr["Mobile Phone"].ToString(),
                            Name = dr["Name"].ToString()
                        }).ToList();

                        Session["EmpoyerContactName"]        = EmpoyerContact[0].Name;
                        Session["EmpoyerContactEmail"]       = EmpoyerContact[0].Email;
                        Session["EmpoyerContactAddress"]     = EmpoyerContact[0].Address;
                        Session["EmpoyerContactMobilePhone"] = EmpoyerContact[0].MobilePhone;

                        if (Url.IsLocalUrl(ReturnUrl) && ReturnUrl.Length > 1 && ReturnUrl.StartsWith("/") && !ReturnUrl.StartsWith("//") && !ReturnUrl.StartsWith("/\\"))
                        {
                            return(Redirect(ReturnUrl));
                        }
                        else
                        {
                            return(RedirectToAction("Index", "Home"));
                        }
                    }
                }

                return(View());
            }
            catch (Exception ex)
            {
                LogError logerror = new LogError();
                logerror.ErrorLog(users.Username, "", "", "Login/Index", "Login", "Index", "ExternalLogin Error", ex.Message.ToString(), 0);
                return(View());
            }
        }
        public JsonResult GetSexRatio()
        {
            string userkey   = ConfigurationManager.AppSettings["userkey"];
            string uid       = ConfigurationManager.AppSettings["uid"];
            string LoginUser = (string)Session["LoginSAPID"];

            try
            {
                Employer.Employer employer = new Employer.Employer();
                DataTable         dt       = employer.FetchCompanYEmployees("1002", userkey, uid);
                dt.TableName = "ExternalUsers";

                dt.Columns.ToString();

                var employeeCount = (from DataRow dr in dt.Rows
                                     select new
                {
                    PIN = dr["P_I_N"].ToString()
                }).ToList();

                var totalCount = employeeCount.Count();

                var sexCount = (from DataRow dr in dt.Rows
                                group dr by dr["SEX"] into g
                                select new
                {
                    Mid = g.Key,
                    Count = g.Count()
                }).ToList();

                var stateCount = (from DataRow dr in dt.Rows
                                  group dr by dr["State of Origin"] into g
                                  select new
                {
                    Mid = g.Key,
                    Count = g.Count()
                }).ToList();

                var religionCount = (from DataRow dr in dt.Rows
                                     group dr by dr["Religion"] into g
                                     select new
                {
                    Mid = g.Key,
                    Count = g.Count()
                }).ToList();

                var maritalStatus = (from DataRow dr in dt.Rows
                                     group dr by dr["Marital Status"] into g
                                     select new
                {
                    Mid = g.Key,
                    Count = g.Count()
                }).ToList();

                var statementOption = (from DataRow dr in dt.Rows
                                       group dr by dr["Statement Option"] into g
                                       select new
                {
                    Mid = g.Key,
                    Count = g.Count()
                }).ToList();

                return(Json(new { sex = sexCount, state = stateCount, religion = religionCount, statement = statementOption, marital = maritalStatus }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                LogError logerror = new LogError();
                logerror.ErrorLog("", LoginUser, "", "Requests/GetRequestCategory", "Requests", "GetRequestCategory", "FetchRequestCategories Error", ex.Message.ToString(), 0);
                return(Json(new { data = "Error has occured" }, JsonRequestBehavior.AllowGet));
            }
        }
Beispiel #26
0
        public ActionResult ForgotPassword(string Username)
        {
            string LoginType;

            try
            {
                string userkey = ConfigurationManager.AppSettings["userkey"];
                string uid     = ConfigurationManager.AppSettings["uid"];

                string ipaddress   = Request.UserHostAddress;
                string Agent       = Request.UserAgent;
                string BrowserUsed = Request.Browser.Browser;

                Employer.Employer employer = new Employer.Employer();

                if ((Username.Trim().Length >= 5) && (Username.Trim().Contains("@") == true) && (Username.Trim().Contains(".") == true))
                {
                    LoginType = "2";
                    var       LoginVal = Username;
                    DataTable dt       = employer.ResetPassword(Username, LoginType, BrowserUsed, uid, userkey, uid);
                    dt.TableName = "ReturnedVal";

                    var response = dt.Columns.Count.ToString();

                    if (response == "2")
                    {
                        var erroStatus = (from DataRow dr in dt.Rows
                                          select new ForgotPassword()
                        {
                            Message = dr["Message"].ToString(),
                            LoginStat = dr["LoginStat"].ToString(),
                        }).ToList();
                        TempData["error"] = erroStatus[0].Message;
                        return(View());
                    }

                    var forgotStatus = (from DataRow dr in dt.Rows
                                        select new ForgotPassword()
                    {
                        Message = dr["Message"].ToString(),
                        LoginStat = dr["LoginStat"].ToString(),
                        RSAPIN = dr["RSAPIN"].ToString()
                    }).ToList();

                    TempData["sMsg"] = forgotStatus[0].Message;
                    return(RedirectToAction("Index"));
                }
                else if ((Username.Trim().Length >= 10) && ((Username.Trim().All(char.IsDigit)) == true))
                {
                    LoginType = "1";
                    var       LoginVal = Username;
                    DataTable dt       = employer.ResetPassword(Username, LoginType, BrowserUsed, uid, userkey, uid);
                    dt.TableName = "ReturnedVal";

                    var response = dt.Columns.Count.ToString();

                    if (response == "2")
                    {
                        var erroStatus = (from DataRow dr in dt.Rows
                                          select new ForgotPassword()
                        {
                            Message = dr["Message"].ToString(),
                            LoginStat = dr["LoginStat"].ToString(),
                        }).ToList();
                        TempData["error"] = erroStatus[0].Message;
                        return(View());
                    }

                    var forgotStatus = (from DataRow dr in dt.Rows
                                        select new ForgotPassword()
                    {
                        Message = dr["Message"].ToString(),
                        LoginStat = dr["LoginStat"].ToString(),
                        RSAPIN = dr["RSAPIN"].ToString()
                    }).ToList();

                    TempData["sMsg"] = forgotStatus[0].Message;
                    return(RedirectToAction("Index"));
                }
                else
                {
                    TempData["error"] = "Email/Password not found";
                    return(View());
                }
            }
            catch (Exception ex)
            {
                LogError logerror = new LogError();
                logerror.ErrorLog(Username, "", "", "Login/ForgotPassword", "Login", "ForgotPassword", "ResetPassword Error", ex.Message.ToString(), 0);
                return(View());
            }
        }
        public JsonResult GetCompanyEmployee([ModelBinder(typeof(DataTablesBinder))] IDataTablesRequest requestModel, String EmployerId)
        {
            string userkey     = ConfigurationManager.AppSettings["userkey"];
            string uid         = ConfigurationManager.AppSettings["uid"];
            string LoginUser   = (string)Session["LoginSAPID"];
            string _access_key = ConfigurationManager.AppSettings["Salt"];

            try
            {
                Employer.Employer employer = new Employer.Employer();
                DataTable         dt       = employer.FetchCompanYEmployees(EmployerId, userkey, uid);
                dt.TableName = "CompanyEmployees";
                Crypto.Service1 _crypt = new Crypto.Service1();


                List <CompanyEmployee> companyEmployee = new List <CompanyEmployee>();
                int startRec = requestModel.Start;
                int pageSize = requestModel.Length;


                List <CompanyEmployee> employeeCount = (from DataRow dr in dt.Rows
                                                        select new CompanyEmployee()
                {
                    PIN = dr["P_I_N"].ToString()
                }).ToList();

                companyEmployee = (from DataRow dr in dt.Rows
                                   select new CompanyEmployee()
                {
                    dPIN = _crypt.Encryptfx(dr["P_I_N"].ToString(), _access_key),
                    PIN = dr["P_I_N"].ToString(),
                    FirstName = dr["First Name"].ToString(),
                    LastName = dr["Last Name"].ToString(),
                    MiddleName = dr["Middle Names"].ToString(),
                    PhoneNo = dr["Mobile 1"].ToString(),
                    DateOfBirth = dr["Date Of Birth"].ToString(),
                    DateOfEmployment = dr["Date Of Employment"].ToString(),
                    Email = dr["E-mail"].ToString(),
                }).Skip(startRec).Take(pageSize).ToList();

                var totalCount    = employeeCount.Count();
                var filteredCount = companyEmployee.Count();

                if (requestModel.Search.Value != string.Empty)
                {
                    var value = requestModel.Search.Value.ToLower().Trim();

                    employeeCount = (from DataRow dr in dt.Rows
                                     where dr["P_I_N"].ToString().ToLower().Contains(value) || dr["First Name"].ToString().ToLower().Contains(value) ||
                                     dr["Last Name"].ToString().ToLower().Contains(value) || dr["Mobile 1"].ToString().ToLower().Contains(value) ||
                                     dr["E-mail"].ToString().ToLower().Contains(value)
                                     select new CompanyEmployee()
                    {
                        PIN = dr["P_I_N"].ToString()
                    }).ToList();

                    companyEmployee = (from DataRow dr in dt.Rows
                                       where dr["P_I_N"].ToString().ToLower().Contains(value) || dr["First Name"].ToString().ToLower().Contains(value) ||
                                       dr["Last Name"].ToString().ToLower().Contains(value) || dr["Mobile 1"].ToString().ToLower().Contains(value) ||
                                       dr["E-mail"].ToString().ToLower().Contains(value)
                                       select new CompanyEmployee()
                    {
                        dPIN = _crypt.Encryptfx(dr["P_I_N"].ToString(), _access_key),
                        PIN = dr["P_I_N"].ToString(),
                        FirstName = dr["First Name"].ToString(),
                        LastName = dr["Last Name"].ToString(),
                        MiddleName = dr["Middle Names"].ToString(),
                        PhoneNo = dr["Mobile 1"].ToString(),
                        DateOfBirth = dr["Date Of Birth"].ToString(),
                        DateOfEmployment = dr["Date Of Employment"].ToString(),
                        Email = dr["E-mail"].ToString(),
                    }).Skip(startRec).Take(pageSize).ToList();

                    totalCount    = employeeCount.Count();
                    filteredCount = companyEmployee.Count();
                }

                var sortedColumns = requestModel.Columns.GetSortedColumns();
                var orderByString = String.Empty;

                foreach (var column in sortedColumns)
                {
                    orderByString += orderByString != String.Empty ? "," : "";
                    orderByString += (column.Data) + (column.SortDirection == Column.OrderDirection.Ascendant ? " asc" : " desc");
                }

                var data = companyEmployee.Select(emList => new
                {
                    //dPIN = emList.dPIN,
                    PIN              = emList.PIN,
                    FirstName        = emList.FirstName,
                    LastName         = emList.LastName,
                    MiddleName       = emList.MiddleName,
                    PhoneNo          = emList.PhoneNo,
                    DateOfBirth      = emList.DateOfBirth,
                    DateOfEmployment = emList.DateOfEmployment,
                    Email            = emList.Email
                }).OrderBy(orderByString == string.Empty ? "PIN asc" : orderByString).ToList();

                return(Json(new DataTablesResponse(requestModel.Draw, data, totalCount, totalCount), JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                LogError logerror = new LogError();
                logerror.ErrorLog("", LoginUser, "", "Employee/GetCompanyEmployee", "Employee", "GetCompanyEmployee", "GetCompanyEmployee Error", ex.Message.ToString(), 0);
                throw new Exception(ex.Message.ToString());
            }
        }
Beispiel #28
0
        public ActionResult Index(Users users, string returnUrl)
        {
            try
            {
                string userkey = ConfigurationManager.AppSettings["userkey"];
                string uid     = ConfigurationManager.AppSettings["uid"];

                string ipaddress   = Request.UserHostAddress;
                string BrowserUsed = Request.UserAgent;

                Employer.Employer employer = new Employer.Employer();
                var LoginStatus            = employer.LOGIN(users.Username, users.Password, BrowserUsed, ipaddress, "", userkey, uid);

                var LoginDetails = LoginStatus.Split('~');

                if (LoginDetails[0] != "01")
                {
                    DataTable dt = employer.FetchRoleView(LoginDetails[3], userkey, uid);
                    dt.TableName = "FetchRolesView";
                    dt.Columns.ToString();

                    List <AdminViews> AdminViews = (from DataRow dr in dt.Rows
                                                    select new AdminViews()
                    {
                        ID = dr["ID"].ToString(),
                        MenuID = dr["MenuID"].ToString(),
                        ParentMenuID = dr["ParentMenuID"].ToString(),
                        ParentMenuName = dr["parentmenyname"].ToString(),
                        MenuName = dr["MenuName"].ToString(),
                        ControllerName = dr["Controller"].ToString(),
                        ActionName = dr["Action"].ToString()
                    }).ToList();

                    var menuView = AdminViews.Cast <AdminViews>().GroupBy(tm => tm.ParentMenuID).Select(group => new { ID = group.Key, Items = group.ToArray() }).ToArray();
                    Session["menuView"] = AdminViews;

                    FormsAuthentication.SetAuthCookie(LoginDetails[1], false);
                    Session["LoginSAPID"] = users.Username;
                    Session["RoleID"]     = LoginDetails[3];
                    Session["WebUserID"]  = LoginDetails[4];
                    if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/") && !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\"))
                    {
                        if (LoginDetails[3] == "1" || LoginDetails[3] == "2")
                        {
                            return(Redirect(returnUrl));
                        }
                        else
                        {
                            return(RedirectToAction("MyRequest", "Requests"));
                        }
                    }
                    else
                    {
                        if (LoginDetails[3] == "1" || LoginDetails[3] == "2")
                        {
                            return(RedirectToAction("Index", "Employers"));
                        }
                        else
                        {
                            return(RedirectToAction("MyRequest", "Requests"));
                        }
                    }
                }
                else
                {
                    TempData["error"] = LoginDetails[1];
                    ViewBag.Error     = TempData["error"];
                    return(View());
                }
            }
            catch (Exception ex)
            {
                LogError logerror = new LogError();
                logerror.ErrorLog(users.Username, "2", "3", "4", "Login", "Index", "Login Error", ex.Message.ToString(), 0);
                TempData["error"] = ex.Message.ToString();
                ViewBag.Error     = TempData["error"];
                return(View());
            }
        }
        public JsonResult GetEmployers([ModelBinder(typeof(DataTablesBinder))] IDataTablesRequest requestModel)
        {
            string userkey   = ConfigurationManager.AppSettings["userkey"];
            string uid       = ConfigurationManager.AppSettings["uid"];
            string LoginUser = (string)Session["LoginSAPID"];
            string RoleID    = (string)Session["RoleID"];
            string WebUserID = (string)Session["WebUserID"];

            try
            {
                if (RoleID == "1")
                {
                    Employer.Employer employer = new Employer.Employer();
                    DataTable         dt       = employer.FetchCompanies("YES", LoginUser);
                    dt.TableName = "Employer";

                    List <Employers> employerList = new List <Employers>();
                    int startRec = requestModel.Start;
                    int pageSize = requestModel.Length;


                    List <Employers> employerCount = (from DataRow dr in dt.Rows
                                                      select new Employers()
                    {
                        EmployerID = dr["EmployerID"].ToString(),
                        CompanyName = dr["Company Name"].ToString(),
                    }).ToList();

                    employerList = (from DataRow dr in dt.Rows
                                    select new Employers()
                    {
                        EmployerID = dr["EmployerID"].ToString(),
                        CompanyName = dr["Company Name"].ToString(),
                        Address1 = dr["Address1"].ToString(),
                        Address2 = dr["Address2"].ToString(),
                        State = dr["State"].ToString(),
                        Email = dr["Email"].ToString(),
                        RelationshipManager = dr["Relationship Manager"].ToString(),
                        RMName = dr["RM Name"].ToString()
                    }).Skip(startRec).Take(pageSize).ToList();

                    var totalCount    = employerCount.Count();
                    var filteredCount = employerList.Count();

                    if (requestModel.Search.Value != string.Empty)
                    {
                        var value = requestModel.Search.Value.ToLower().Trim();

                        employerCount = (from DataRow dr in dt.Rows
                                         where dr["EmployerID"].ToString().ToLower().Contains(value) || dr["Company Name"].ToString().ToLower().Contains(value) ||
                                         dr["Email"].ToString().ToLower().Contains(value) || dr["Relationship Manager"].ToString().ToLower().Contains(value) ||
                                         dr["RM Name"].ToString().ToLower().Contains(value)
                                         select new Employers()
                        {
                            EmployerID = dr["EmployerID"].ToString(),
                            CompanyName = dr["Company Name"].ToString(),
                        }).ToList();

                        employerList = (from DataRow dr in dt.Rows
                                        where dr["EmployerID"].ToString().ToLower().Contains(value) || dr["Company Name"].ToString().ToLower().Contains(value) ||
                                        dr["Email"].ToString().ToLower().Contains(value) || dr["Relationship Manager"].ToString().ToLower().Contains(value) ||
                                        dr["RM Name"].ToString().ToLower().Contains(value)
                                        select new Employers()
                        {
                            EmployerID = dr["EmployerID"].ToString(),
                            CompanyName = dr["Company Name"].ToString(),
                            Address1 = dr["Address1"].ToString(),
                            Address2 = dr["Address2"].ToString(),
                            State = dr["State"].ToString(),
                            Email = dr["Email"].ToString(),
                            RelationshipManager = dr["Relationship Manager"].ToString(),
                            RMName = dr["RM Name"].ToString()
                        }).Skip(startRec).Take(pageSize).ToList();

                        totalCount    = employerCount.Count();
                        filteredCount = employerList.Count();
                    }

                    var sortedColumns = requestModel.Columns.GetSortedColumns();
                    var orderByString = String.Empty;

                    foreach (var column in sortedColumns)
                    {
                        orderByString += orderByString != String.Empty ? "," : "";
                        orderByString += (column.Data) + (column.SortDirection == Column.OrderDirection.Ascendant ? " asc" : " desc");
                    }

                    var data = employerList.Select(emList => new
                    {
                        EmployerID          = emList.EmployerID,
                        CompanyName         = emList.CompanyName,
                        Address1            = emList.Address1,
                        Address2            = emList.Address2,
                        State               = emList.State,
                        Email               = emList.Email,
                        RelationshipManager = emList.RelationshipManager,
                        RMName              = emList.RMName
                    }).OrderBy(orderByString == string.Empty ? "EmployerID asc" : orderByString).ToList();

                    return(Json(new DataTablesResponse(requestModel.Draw, data, totalCount, totalCount), JsonRequestBehavior.AllowGet));
                }
                else
                {
                    Employer.Employer employer = new Employer.Employer();
                    DataTable         dt       = employer.FetchCompanies("All", "");
                    dt.TableName = "Employer";

                    List <Employers> employerList = new List <Employers>();
                    int startRec = requestModel.Start;
                    int pageSize = requestModel.Length;


                    List <Employers> employerCount = (from DataRow dr in dt.Rows
                                                      select new Employers()
                    {
                        EmployerID = dr["EmployerID"].ToString(),
                        CompanyName = dr["Company Name"].ToString(),
                    }).ToList();

                    employerList = (from DataRow dr in dt.Rows
                                    select new Employers()
                    {
                        EmployerID = dr["EmployerID"].ToString(),
                        CompanyName = dr["Company Name"].ToString(),
                        Address1 = dr["Address1"].ToString(),
                        Address2 = dr["Address2"].ToString(),
                        State = dr["State"].ToString(),
                        Email = dr["Email"].ToString(),
                        RelationshipManager = dr["Relationship Manager"].ToString(),
                        RMName = dr["RM Name"].ToString()
                    }).Skip(startRec).Take(pageSize).ToList();

                    var totalCount    = employerCount.Count();
                    var filteredCount = employerList.Count();

                    if (requestModel.Search.Value != string.Empty)
                    {
                        var value = requestModel.Search.Value.ToLower().Trim();

                        employerCount = (from DataRow dr in dt.Rows
                                         where dr["EmployerID"].ToString().ToLower().Contains(value) || dr["Company Name"].ToString().ToLower().Contains(value) ||
                                         dr["Email"].ToString().ToLower().Contains(value) || dr["Relationship Manager"].ToString().ToLower().Contains(value) ||
                                         dr["RM Name"].ToString().ToLower().Contains(value)
                                         select new Employers()
                        {
                            EmployerID = dr["EmployerID"].ToString(),
                            CompanyName = dr["Company Name"].ToString(),
                        }).ToList();

                        employerList = (from DataRow dr in dt.Rows
                                        where dr["EmployerID"].ToString().ToLower().Contains(value) || dr["Company Name"].ToString().ToLower().Contains(value) ||
                                        dr["Email"].ToString().ToLower().Contains(value) || dr["Relationship Manager"].ToString().ToLower().Contains(value) ||
                                        dr["RM Name"].ToString().ToLower().Contains(value)
                                        select new Employers()
                        {
                            EmployerID = dr["EmployerID"].ToString(),
                            CompanyName = dr["Company Name"].ToString(),
                            Address1 = dr["Address1"].ToString(),
                            Address2 = dr["Address2"].ToString(),
                            State = dr["State"].ToString(),
                            Email = dr["Email"].ToString(),
                            RelationshipManager = dr["Relationship Manager"].ToString(),
                            RMName = dr["RM Name"].ToString()
                        }).Skip(startRec).Take(pageSize).ToList();

                        totalCount    = employerCount.Count();
                        filteredCount = employerList.Count();
                    }

                    var sortedColumns = requestModel.Columns.GetSortedColumns();
                    var orderByString = String.Empty;

                    foreach (var column in sortedColumns)
                    {
                        orderByString += orderByString != String.Empty ? "," : "";
                        orderByString += (column.Data) + (column.SortDirection == Column.OrderDirection.Ascendant ? " asc" : " desc");
                    }

                    var data = employerList.Select(emList => new
                    {
                        EmployerID          = emList.EmployerID,
                        CompanyName         = emList.CompanyName,
                        Address1            = emList.Address1,
                        Address2            = emList.Address2,
                        State               = emList.State,
                        Email               = emList.Email,
                        RelationshipManager = emList.RelationshipManager,
                        RMName              = emList.RMName
                    }).OrderBy(orderByString == string.Empty ? "EmployerID asc" : orderByString).ToList();

                    return(Json(new DataTablesResponse(requestModel.Draw, data, totalCount, totalCount), JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception ex)
            {
                LogError logerror = new LogError();
                logerror.ErrorLog("", LoginUser, "", "Employer/GetEmployers", "Employer", "GetEmployers", "GetEmployers Error", ex.Message.ToString(), 0);
                throw new Exception(ex.Message.ToString());
            }
        }
        public JsonResult GetEmployerContacts([ModelBinder(typeof(DataTablesBinder))] IDataTablesRequest requestModel, string EmployerId)
        {
            string userkey   = ConfigurationManager.AppSettings["userkey"];
            string uid       = ConfigurationManager.AppSettings["uid"];
            string LoginUser = (string)Session["LoginSAPID"];

            try
            {
                Employer.Employer employer = new Employer.Employer();
                DataTable         dt       = employer.FetchExternalUsers(true, EmployerId, userkey, uid);

                dt.TableName = "ExternalUsers";
                dt.Columns.ToString();

                List <ExternalUsers> userList = new List <ExternalUsers>();
                int startRec = requestModel.Start;
                int pageSize = requestModel.Length;

                List <ExternalUsers> usersCount = (from DataRow dr in dt.Rows
                                                   select new ExternalUsers()
                {
                    ID = dr["ID"].ToString()
                }).ToList();

                userList = (from DataRow dr in dt.Rows
                            select new ExternalUsers()
                {
                    ID = dr["ID"].ToString(),
                    EMAIL = dr["EMAIL"].ToString(),
                    PHONE = dr["PHONE"].ToString(),
                    FULLNAME = dr["FULLNAME"].ToString(),
                    LOCKED = dr["LOCKED"].ToString(),
                    STATUS = dr["STATUS"].ToString(),
                    PCODE = dr["PCODE"].ToString(),
                    ROLE_ID = dr["ROLE_ID"].ToString(),

                    /*STATUS = dr["EMPLOYER_ID"].ToString(),
                     * STATUS = dr["APPROVAL_STATUS"].ToString(),
                     * STATUS = dr["CREATED_BY"].ToString(),
                     * STATUS = dr["DATE_CREATED"].ToString(),
                     * STATUS = dr["APPROVED_BY"].ToString(),
                     * STATUS = dr["STATUS"].ToString(),
                     * DATE_LAST_MODIFIED = dr["DATE_APPROVED"].ToString()*/
                }).Skip(startRec).Take(pageSize).ToList();

                var totalCount    = usersCount.Count();
                var filteredCount = userList.Count();

                if (requestModel.Search.Value != string.Empty)
                {
                    var value = requestModel.Search.Value.ToLower().Trim();

                    usersCount = (from DataRow dr in dt.Rows
                                  where dr["ID"].ToString().ToLower().Contains(value) || dr["EMAIL"].ToString().ToLower().Contains(value) ||
                                  dr["FULLNAME"].ToString().ToLower().Contains(value) || dr["PHONE"].ToString().ToLower().Contains(value)
                                  select new ExternalUsers()
                    {
                        ID = dr["ID"].ToString()
                    }).ToList();

                    userList = (from DataRow dr in dt.Rows
                                where dr["ID"].ToString().ToLower().Contains(value) || dr["EMAIL"].ToString().ToLower().Contains(value) ||
                                dr["FULLNAME"].ToString().ToLower().Contains(value) || dr["PHONE"].ToString().ToLower().Contains(value)
                                select new ExternalUsers()
                    {
                        ID = dr["ID"].ToString(),
                        EMAIL = dr["EMAIL"].ToString(),
                        PHONE = dr["PHONE"].ToString(),
                        FULLNAME = dr["FULLNAME"].ToString(),
                        LOCKED = dr["LOCKED"].ToString(),
                        STATUS = dr["STATUS"].ToString(),
                        PCODE = dr["PCODE"].ToString(),
                        ROLE_ID = dr["ROLE_ID"].ToString(),

                        /*STATUS = dr["EMPLOYER_ID"].ToString(),
                         * STATUS = dr["APPROVAL_STATUS"].ToString(),
                         * STATUS = dr["CREATED_BY"].ToString(),
                         * STATUS = dr["DATE_CREATED"].ToString(),
                         * STATUS = dr["APPROVED_BY"].ToString(),
                         * STATUS = dr["STATUS"].ToString(),*/
                        DATE_LAST_MODIFIED = dr["DATE_APPROVED"].ToString()
                    }).Skip(startRec).Take(pageSize).ToList();

                    totalCount    = usersCount.Count();
                    filteredCount = userList.Count();
                }

                var sortedColumns = requestModel.Columns.GetSortedColumns();
                var orderByString = String.Empty;

                foreach (var column in sortedColumns)
                {
                    orderByString += orderByString != String.Empty ? "," : "";
                    orderByString += (column.Data) + (column.SortDirection == Column.OrderDirection.Ascendant ? " asc" : " desc");
                }

                var data = userList.Select(emList => new
                {
                    ID                 = emList.ID,
                    PHONE              = emList.PHONE,
                    FULLNAME           = emList.FULLNAME,
                    EMAIL              = emList.EMAIL,
                    LOCKED             = emList.LOCKED,
                    STATUS             = emList.STATUS,
                    ROLE_ID            = emList.ROLE_ID,
                    DATE_LAST_MODIFIED = emList.DATE_LAST_MODIFIED
                }).OrderBy(orderByString == string.Empty ? "ID asc" : orderByString).ToList();

                return(Json(new DataTablesResponse(requestModel.Draw, data, totalCount, totalCount), JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                LogError logerror = new LogError();
                logerror.ErrorLog("", LoginUser, "", "Admin/GetInternalUsers", "Admin", "GetExternalUsers", "FetchExternalUsers Error", ex.Message.ToString(), 0);
                throw new Exception(ex.Message.ToString());
            }
        }