Ejemplo n.º 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));
            }
        }
Ejemplo n.º 2
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"));
            }
        }
Ejemplo n.º 3
0
        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"));
            }
        }
Ejemplo n.º 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());
            }
        }
Ejemplo n.º 5
0
        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());
            }
        }
Ejemplo n.º 6
0
        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));
            }
        }
Ejemplo n.º 7
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());;
            }
        }
Ejemplo n.º 8
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());
            }
        }
Ejemplo n.º 9
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));
            }
        }
Ejemplo n.º 10
0
        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());
            }
        }
Ejemplo n.º 11
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));
            }
        }
Ejemplo n.º 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));
            }
        }
Ejemplo n.º 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"));
            }
        }
Ejemplo n.º 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());
            }
        }
Ejemplo n.º 15
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());
            }
        }
Ejemplo n.º 16
0
        public JsonResult GetAllViews()
        {
            string userkey   = ConfigurationManager.AppSettings["userkey"];
            string uid       = ConfigurationManager.AppSettings["uid"];
            string LoginUser = (string)Session["LoginSAPID"];

            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();

            return(Json(new { data = adminViews }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 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());
            }
        }
Ejemplo n.º 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());
            }
        }
Ejemplo n.º 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());
            }
        }
Ejemplo n.º 20
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());
            }
        }
Ejemplo n.º 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());
            }
        }
Ejemplo n.º 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());
            }
        }
Ejemplo n.º 23
0
        public string ErrorLog(string RecordID, string RecordID2, string RecordID3, string Section, string Section2, string Section3, string Description, string Verbose, int Status)
        {
            try
            {
                int iS1 = Section.Length;
                int iS2 = Section2.Length;
                int iS3 = Section3.Length;
                int iD  = Description.Length;
                int iV  = Verbose.Length;

                if (iS1 > 300)
                {
                    iS1 = 300;
                }
                if (iS2 > 50)
                {
                    iS2 = 50;
                }
                if (iS3 > 50)
                {
                    iS3 = 50;
                }
                if (iD > 300)
                {
                    iD = 300;
                }
                if (iV > 300)
                {
                    iV = 300;
                }

                string retVal = "";
                try
                {
                    //call logerror API here
                    Employer.Employer employer = new Employer.Employer();
                    retVal = employer.LogError(RecordID, RecordID2, RecordID3,
                                               Section.Substring(0, iS1),
                                               Section2.Substring(0, iS2),
                                               Section3.Substring(0, iS3),
                                               Description.Substring(0, iD),
                                               Verbose.Substring(0, iV),
                                               Status);
                }
                catch (Exception ex)
                {
                    LogWorker logworker = new LogWorker("ErrorLog", "ErrorLog", ex.Message.ToString());
                }

                string[] retValParser;
                retValParser = retVal.Split('~');
                if (retValParser.GetUpperBound(0) > 0)
                {
                    if (retValParser[0] != "0")
                    {
                        return(retValParser[1]);
                    }
                    else
                    {
                        //UserID | ClientID | EntityID
                        this.WriteToLog(RecordID + "|" + RecordID2 + "|" + RecordID3 + "\t" + Section + "\t" + Section2 + "\t" + Section3 + "\t" + Description + "\t" + Verbose);
                        return(retValParser[1]);
                    }
                }
                else
                {
                    return(retVal);
                }
            }
            catch (Exception ex)
            {
                try
                {
                    this.WriteToLog(RecordID + "\t" + Section + "\t" + Section2 + "\t" + Section3 + "\t" + Description + "\t" + Verbose);
                }catch (Exception exx) {
                    LogWorker logworker = new LogWorker("LogError", "ErrorLog", exx.Message.ToString());
                }
            }
            return("");
        }
Ejemplo n.º 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());
            }
        }
Ejemplo n.º 25
0
        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));
            }
        }
Ejemplo n.º 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());
            }
        }
Ejemplo n.º 27
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());
            }
        }
Ejemplo n.º 28
0
        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());
            }
        }
Ejemplo n.º 29
0
        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());
            }
        }
Ejemplo n.º 30
0
        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());
            }
        }