public ActionResult Login(Employee_Login objUser) { /******************************************************************* * Author : Gopi * Date : 04/07/2017 * Description : Validating User login *******************************************************************/ var res = string.Empty; using (fze = new FiestaZohoDatabaseEntities()) { objUser.password = Convert.ToBase64String( System.Security.Cryptography.SHA256.Create() .ComputeHash(Encoding.UTF8.GetBytes(objUser.password))); var usr = fze.ValidateLogin(objUser.emailEmployee, objUser.password).ToList(); if (usr != null && usr.Count() > 0) { Session["UserID"] = usr[0].EmpId.ToString(); Session["UserName"] = usr[0].EmployeeName.ToString(); Session["UserEmail"] = usr[0].EmailAddress.ToString(); Session["UserRole"] = usr[0].RoleId; } else { res = "Email or Password is wrong."; } } // } return(Json(res, JsonRequestBehavior.AllowGet)); }
public ActionResult RegisterEmployee(Employee emp) { /******************************************************************* * Author : Gopi * Date : 04/07/2017 * Description : saves new registerd employee details *******************************************************************/ EmployeeRegistration_Result objRes = new EmployeeRegistration_Result(); using (fze = new FiestaZohoDatabaseEntities()) { string encrpassword = Convert.ToBase64String( System.Security.Cryptography.SHA256.Create() .ComputeHash(Encoding.UTF8.GetBytes(emp.password))); objRes = fze.EmployeeRegistration(emp.firstName, emp.lastName, emp.emailEmployee, encrpassword).FirstOrDefault(); ModelState.Clear(); if (objRes.Status.Equals("Success")) { objRes.Status = emp.firstName + " " + emp.lastName + " ( " + emp.emailEmployee + " ) " + " is successfully registered."; } } return(Json(objRes, JsonRequestBehavior.AllowGet)); // } }
public ActionResult AssignEmployee(Employee_Assign obj) { /******************************************************************* * Author : Gopi * Date : 04/07/2017 * Description : Assigning states, stores and role for the employee *******************************************************************/ var msg = ""; try { using (fze = new FiestaZohoDatabaseEntities()) { fze.UpdateEmployeeRole(obj.EmployeeId, obj.RoleId); if (obj.RoleId > 1) { fze.InsertEmployeeDetails(obj.EmployeeId, obj.States, obj.Stores); //foreach (string store in obj.lstStores) //{ // fze.InsertEmployeeStores(obj.EmployeeId, store); //} } } msg = "Successfully Assigned."; } catch (Exception ex) { msg = "Something went wrong."; } return(Json(msg, JsonRequestBehavior.AllowGet)); }
public ActionResult GetStates() { /******************************************************************* * Author : Gopi * Date : 04/07/2017 * Description : Returns all the states by role *******************************************************************/ var objStates = new List <GetAllStates_Result>(); using (fze = new FiestaZohoDatabaseEntities()) { objStates = fze.GetAllStates(Convert.ToInt32(Session["UserRole"]), Convert.ToInt32(Session["UserID"])).ToList(); } return(Json(objStates, JsonRequestBehavior.AllowGet)); }
public ActionResult GetStores(StoresReq objReq) { /******************************************************************* * Author : Gopi * Date : 04/07/2017 * Description : Returns stores by state *******************************************************************/ var objStores = new List <GetStoresByState_Result>(); using (fze = new FiestaZohoDatabaseEntities()) { objStores = fze.GetStoresByState(objReq.States, Convert.ToInt32(Session["UserRole"]), objReq.EmpId, Convert.ToInt32(Session["UserID"])).ToList(); } return(Json(objStores, JsonRequestBehavior.AllowGet)); }
public ActionResult GetRoles() { /******************************************************************* * Author : Gopi * Date : 04/07/2017 * Description :Returns all the role types by loggedin user role *******************************************************************/ var objRoles = new List <GetRolesByEmp_Result>(); using (fze = new FiestaZohoDatabaseEntities()) { objRoles = fze.GetRolesByEmp(Convert.ToInt32(Session["UserRole"])).ToList(); } return(Json(objRoles, JsonRequestBehavior.AllowGet)); }
public ActionResult GetEmployeeByEmail(string Email) { /******************************************************************* * Author : Gopi * Date : 04/07/2017 * Description : Returns Employee details by Email address *******************************************************************/ var objSearch = new Employee_Search(); using (fze = new FiestaZohoDatabaseEntities()) { var lst = fze.GetEmployeeDetailsByEmail(Email).ToList(); if (lst.Count > 0) { objSearch.EmpDetails = lst[0]; objSearch.lstStates = fze.GetAllStates(objSearch.EmpDetails.RoleId, objSearch.EmpDetails.EmpId).ToList(); objSearch.lstStores = fze.GetStoresByState(string.Empty, objSearch.EmpDetails.RoleId, objSearch.EmpDetails.EmpId, Convert.ToInt32(Session["UserID"])).ToList(); } } return(Json(objSearch, JsonRequestBehavior.AllowGet)); }
public ActionResult AssignReports(Employee_AssignReports obj) { /******************************************************************* * Author : Gopi * Date : 04/07/2017 * Description : Assigning reports for the employee *******************************************************************/ using (fze = new FiestaZohoDatabaseEntities()) { foreach (string store in obj.lstStores) { fze.DeleteReportsByStore(obj.EmployeeId, store); if (obj.lstReports != null) { foreach (int report in obj.lstReports) { fze.InsertEmployeeReports(obj.EmployeeId, store, report); } } } } return(Json("Success", JsonRequestBehavior.AllowGet)); }
public ActionResult UploadExcel(String nameReport) { /******************************************************************* * Author : Gopi * Date : 04/07/2017 * Description : Imports excel file data into specific reports table *******************************************************************/ try { ViewData["Message"] = ""; int i = Request.Files.Count; HttpPostedFileBase uploadFile = Request.Files[0]; if ((uploadFile.ContentLength > 0) && (uploadFile != null)) { if (uploadFile.ContentType == "application/vnd.ms-excel" || uploadFile.ContentType == "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet") { if (nameReport == "RP") { TempData["RP_Message"] = ""; string filename = Path.GetFileName(uploadFile.FileName); string extn = filename.Split('.').ElementAt(1); extn = '.' + extn; Guid id = Guid.NewGuid(); string file = id + extn; uploadFile.SaveAs(Server.MapPath("~/UploadedFiles/RP/") + file); using (fze = new FiestaZohoDatabaseEntities()) { fze.InsertFileUploads(filename, Convert.ToString(Session["UserEmail"]), nameReport, id); } TempData["RP_Message"] = "file has been uploaded"; } if (nameReport == "AR") { TempData["AR_Message"] = ""; string filename = Path.GetFileName(uploadFile.FileName); string extn = filename.Split('.').ElementAt(1); extn = '.' + extn; Guid id = Guid.NewGuid(); string file = id + extn; uploadFile.SaveAs(Server.MapPath("~/UploadedFiles/AR/") + file); using (fze = new FiestaZohoDatabaseEntities()) { fze.InsertFileUploads(filename, Convert.ToString(Session["UserEmail"]), nameReport, id); } TempData["AR_Message"] = "file has been uploaded"; } if (nameReport == "EFT") { TempData["EFT_Message"] = ""; string filename = Path.GetFileName(uploadFile.FileName); string extn = filename.Split('.').ElementAt(1); extn = '.' + extn; Guid id = Guid.NewGuid(); string file = id + extn; uploadFile.SaveAs(Server.MapPath("~/UploadedFiles/EFT/") + file); using (fze = new FiestaZohoDatabaseEntities()) { fze.InsertFileUploads(filename, Convert.ToString(Session["UserEmail"]), nameReport, id); } TempData["EFT_Message"] = "file has been uploaded"; } if (nameReport == "RECON") { TempData["Recon_Message"] = ""; string filename = Path.GetFileName(uploadFile.FileName); string extn = filename.Split('.').ElementAt(1); extn = '.' + extn; Guid id = Guid.NewGuid(); string file = id + extn; uploadFile.SaveAs(Server.MapPath("~/UploadedFiles/RECON/") + file); using (fze = new FiestaZohoDatabaseEntities()) { fze.InsertFileUploads(filename, Convert.ToString(Session["UserEmail"]), nameReport, id); } TempData["Recon_Message"] = "file has been uploaded"; } if (nameReport == "EOD") { TempData["DD_Message"] = ""; string filename = Path.GetFileName(uploadFile.FileName); string extn = filename.Split('.').ElementAt(1); extn = '.' + extn; Guid id = Guid.NewGuid(); string file = id + extn; uploadFile.SaveAs(Server.MapPath("~/UploadedFiles/DD/") + file); using (fze = new FiestaZohoDatabaseEntities()) { fze.InsertFileUploads(filename, Convert.ToString(Session["UserEmail"]), nameReport, id); } TempData["DD_Message"] = "file has been uploaded"; } if (nameReport == "COMMISSION") { TempData["Commission_Message"] = ""; string filename = Path.GetFileName(uploadFile.FileName); string extn = filename.Split('.').ElementAt(1); extn = '.' + extn; Guid id = Guid.NewGuid(); string file = id + extn; uploadFile.SaveAs(Server.MapPath("~/UploadedFiles/COMMISSION/") + file); using (fze = new FiestaZohoDatabaseEntities()) { fze.InsertFileUploads(filename, Convert.ToString(Session["UserEmail"]), nameReport, id); } TempData["Commission_Message"] = "file has been uploaded"; } } else { TempData["ExcelMissing_Message"] = ""; TempData["ExcelMissing_Message"] = "must select an Excel file to upload"; } } else { TempData["ExcelMissing_Message"] = ""; TempData["ExcelMissing_Message"] = "must select an Excel file to upload"; } } catch (Exception ex) { TempData["MessageException"] = "The following error occured: " + ex.Message; } return(View("UploadExcel")); }