public bool SetRepresentative(string repname, HttpSessionStateBase session) { if (repname is null) { session["MessageBack"] = "Please choose an employee to represent"; return(false); } string[] emplist = (string[])session["AuthEmployeeList"]; if (!emplist.Contains(repname)) { session["MessageBack"] = "No such employee (" + repname + ") in this department"; return(false); } session["MessageBack"] = ""; string deptid = session["DepartmentID"].ToString(); DeptCollectionDetail deptDetails = db.DeptCollectionDetails.Where(x => x.departmentId == deptid).First(); string newrepID = new string(repname.Where(Char.IsDigit).ToArray()); string username = session["Username"].ToString(); string password = session["Password"].ToString(); string statusMessage = WebAccessSetRepresentative(username, password, newrepID); if (statusMessage == "Success") { deptDetails.representative = newrepID; EmailBusinessLogic emailBizLogic = new EmailBusinessLogic(); string sender = session["EmployeeID"].ToString(); string receipient = newrepID; emailBizLogic.SendEmail("assignRep", receipient, sender, null, null, null); } db.SaveChangesAsync(); return(true); }
public async Task CancelAuthorisedPerson(HttpSessionStateBase session) { string deptid = session["DepartmentID"].ToString(); DeptCollectionDetail deptDetails = db.DeptCollectionDetails.Where(x => x.departmentId == deptid).First(); if (deptDetails.authorisedPerson == null) { return; } string newempID = ""; string username = session["Username"].ToString(); string password = session["Password"].ToString(); string statusMessage = WebAccessSetAuthorisedPerson(username, password, newempID); if (statusMessage == "Success") { string removedAuth = db.DeptCollectionDetails.Find(deptid).authorisedPerson; EmailBusinessLogic emailBizLogic = new EmailBusinessLogic(); string sender = session["EmployeeID"].ToString(); string receipient = removedAuth; emailBizLogic.SendEmail("removeAuth", receipient, sender, null, null, null); db.DeptCollectionDetails.Find(deptid).authorisedPerson = null; db.DeptCollectionDetails.Find(deptid).validDateStart = null; db.DeptCollectionDetails.Find(deptid).validDateEnd = null; } else { return; } await db.SaveChangesAsync(); }
public string CancelRepresentativeWebAPI(string deptID, string headID, string username, string password) { if (db.DeptCollectionDetails.Find(deptID).representative == null) { return("Success"); } DeptCollectionDetail deptDetails = db.DeptCollectionDetails.Where(x => x.departmentId == deptID).First(); string newrepID = ""; string statusMessage = WebAccessSetRepresentative(username, password, newrepID); if (statusMessage == "Success") { string removedRep = db.DeptCollectionDetails.Find(deptID).representative; db.DeptCollectionDetails.Find(deptID).representative = null; EmailBusinessLogic emailBizLogic = new EmailBusinessLogic(); string sender = headID; string receipient = removedRep; emailBizLogic.SendEmail("removeRep", receipient, sender, null, null, null); } else { return(statusMessage); } db.SaveChangesAsync(); return("Success"); }
public async Task CancelRepresentative(string deptId, HttpSessionStateBase session) { if (db.DeptCollectionDetails.Find(deptId).representative == null) { return; } string deptid = session["DepartmentID"].ToString(); DeptCollectionDetail deptDetails = db.DeptCollectionDetails.Where(x => x.departmentId == deptid).First(); string newrepID = ""; string username = session["Username"].ToString(); string password = session["Password"].ToString(); string statusMessage = WebAccessSetRepresentative(username, password, newrepID); if (statusMessage == "Success") { string removedRep = db.DeptCollectionDetails.Find(deptId).representative; db.DeptCollectionDetails.Find(deptId).representative = null; EmailBusinessLogic emailBizLogic = new EmailBusinessLogic(); string sender = session["EmployeeID"].ToString(); string receipient = removedRep; emailBizLogic.SendEmail("removeRep", receipient, sender, null, null, null); } else { return; } await db.SaveChangesAsync(); }
public string SetRepresentativeWebAPI(string newrepid, string deptID, string headID, string username, string password) { Dictionary <string, string> emplist = GetEmployeeList(username, password, deptID); if (newrepid is null) { return("Please choose an employee to represent"); } if (!emplist.ContainsKey(newrepid)) { return("No such employee of id:" + newrepid + " in this department"); } DeptCollectionDetail deptDetails = db.DeptCollectionDetails.Where(x => x.departmentId == deptID).First(); string statusMessage = WebAccessSetRepresentative(username, password, newrepid); if (statusMessage == "Success") { deptDetails.representative = newrepid; EmailBusinessLogic emailBizLogic = new EmailBusinessLogic(); string sender = headID; string receipient = newrepid; emailBizLogic.SendEmail("assignRep", receipient, sender, null, null, null); } db.SaveChangesAsync(); return("Success"); }
public Requisition RequisitionFormGeneration(HttpSessionStateBase session, RequisitionFormItemCart itemcart) { DeptCollectionDetail dept = db.DeptCollectionDetails.ToList <DeptCollectionDetail>().Where(x => x.departmentId == session["DepartmentID"].ToString()).First(); string authPerson = dept.authorisedPerson; Requisition requisition = new Requisition(); if (authPerson != null && dept.validDateStart < DateTime.Now && dept.validDateEnd > DateTime.Now) { requisition.approvalPerson = authPerson; } else { requisition.approvalPerson = session["HeadID"].ToString(); } requisition.employee = session["EmployeeID"].ToString(); requisition.requisitionId = "REQ-" + session["DepartmentID"].ToString() + "-" + session["EmployeeID"].ToString() + "-" + DateTime.Now.ToString("yyMMddhhmmss"); requisition.departmentId = session["DepartmentID"].ToString(); requisition.RequisitionDetails = itemcart.RequestItemCart(); foreach (RequisitionDetail x in requisition.RequisitionDetails) { x.requisitionId = requisition.requisitionId; x.transId = 0; } requisition.requestDate = DateTime.Now; return(requisition); }
public Dictionary <string, string> RetrieveCurrentCollectionInfo(string deptID, Dictionary <string, string> tempdata) { DeptCollectionDetail deptCollectionDetail = db.DeptCollectionDetails.Where(x => x.departmentId == deptID).First(); CollectionPoint collectPoint = db.CollectionPoints.Where(y => y.locationName == deptCollectionDetail.collectionPoint).First(); tempdata.Add("CollectPoint", deptCollectionDetail.collectionPoint); tempdata.Add("CollectTime", collectPoint.collectTime); return(tempdata); }
public bool SetAuthorisedPerson(string authperson, string startdate, string enddate, HttpSessionStateBase session) { if (authperson is null || startdate is null || enddate is null) { session["MessageBack"] = "Please enter all necessary fields"; return(false); } string[] emplist = (string[])session["AuthEmployeeList"]; if (!emplist.Contains(authperson)) { session["MessageBack"] = "No such employee (" + authperson + ") in this department"; return(false); } DateTime startDate = new DateTime(); DateTime endDate = new DateTime(); DateTime.TryParse(startdate, out startDate); DateTime.TryParse(enddate, out endDate); DateTime compareDate = DateTime.Now.Date; if (startDate < compareDate || endDate < compareDate) { session["MessageBack"] = "Please ensure both start date (" + startdate + ") and end date (" + enddate + ") are not earlier the date today (" + compareDate.ToString() + ")"; return(false); } if (startDate > endDate) { session["MessageBack"] = "Your selected start date " + startdate + "is earlier than your selected end date " + enddate; return(false); } session["MessageBack"] = ""; string deptid = session["DepartmentID"].ToString(); DeptCollectionDetail deptDetails = db.DeptCollectionDetails.Where(x => x.departmentId == deptid).First(); string newempID = new string(authperson.Where(Char.IsDigit).ToArray()); string username = session["Username"].ToString(); string password = session["Password"].ToString(); string statusMessage = WebAccessSetAuthorisedPerson(username, password, newempID); if (statusMessage == "Success") { deptDetails.authorisedPerson = newempID; deptDetails.validDateStart = startDate; deptDetails.validDateEnd = endDate; } else { return(false); } db.SaveChanges(); EmailBusinessLogic emailBizLogic = new EmailBusinessLogic(); string sender = session["EmployeeID"].ToString(); string receipient = newempID; emailBizLogic.SendEmail("assignAuth", receipient, sender, null, null, null); return(true); }
public string SetAuthorisedPersonWebAPI(string authperson, string headID, string deptID, string startdate, string enddate, string username, string password) { Dictionary <string, string> emplist = GetEmployeeList(username, password, deptID); if (deptID is null || startdate is null || enddate is null) { return("Important Parameters cannot be null"); } if (!emplist.ContainsKey(authperson)) { return("Please ensure that employee authorised is in your department"); } DateTime startDate = new DateTime(); DateTime endDate = new DateTime(); bool date1pass = DateTime.TryParse(startdate, out startDate); bool date2pass = DateTime.TryParse(enddate, out endDate); DateTime compareDate = DateTime.Now.Date; if (!date1pass || !date2pass) { return("Please ensure dates are in valid format"); } if (startDate < compareDate || endDate < compareDate) { return("Please ensure both start date (" + startdate + ") and end date (" + enddate + ") are not earlier the date today (" + compareDate.ToString() + ")"); } if (startDate > endDate) { return("Your selected start date " + startdate + "is earlier than your selected end date " + enddate); } DeptCollectionDetail deptDetails = db.DeptCollectionDetails.Where(x => x.departmentId == deptID).First(); string statusMessage = WebAccessSetAuthorisedPerson(username, password, authperson); if (statusMessage == "Success") { deptDetails.authorisedPerson = authperson; deptDetails.validDateStart = startDate; deptDetails.validDateEnd = endDate; } else { return(statusMessage); } db.SaveChanges(); EmailBusinessLogic emailBizLogic = new EmailBusinessLogic(); string sender = headID; string receipient = authperson; emailBizLogic.SendEmail("assignAuth", receipient, sender, null, null, null); return("ok"); }
public async Task SetCurrentCollectionInfo(string deptID, string selection) { DeptCollectionDetail deptCollectionDetail = db.DeptCollectionDetails.Where(x => x.departmentId == deptID).First(); List <CollectionPoint> collectionPoints = db.CollectionPoints.ToList <CollectionPoint>(); foreach (CollectionPoint x in collectionPoints) { if (selection.Contains(x.locationName)) { deptCollectionDetail.collectionPoint = x.locationName; break; } } await db.SaveChangesAsync(); }
public bool checkHeadValid(HttpSessionStateBase session) { string deptID = session["DepartmentID"].ToString(); if (deptID == "STOR") { return(true); } DeptCollectionDetail deptCP = db.DeptCollectionDetails.Where(x => x.departmentId == deptID).First(); DateTime time = DateTime.Now; if (deptCP.authorisedPerson is null || deptCP.validDateEnd < time.Date) { return(true); }
public string CancelAuthorisedPersonWebAPI(string headID, string deptID, string username, string password) { DeptCollectionDetail deptDetails = db.DeptCollectionDetails.Where(x => x.departmentId == deptID).First(); if (deptDetails == null) { return("No such department exits"); } else { if (deptDetails.authorisedPerson == null) { return("Success"); } } string newempID = ""; string statusMessage = WebAccessSetAuthorisedPerson(username, password, newempID); if (statusMessage == "Success") { string removedAuth = db.DeptCollectionDetails.Find(deptID).authorisedPerson; EmailBusinessLogic emailBizLogic = new EmailBusinessLogic(); string sender = headID; string receipient = removedAuth; emailBizLogic.SendEmail("removeAuth", receipient, sender, null, null, null); db.DeptCollectionDetails.Find(deptID).authorisedPerson = null; db.DeptCollectionDetails.Find(deptID).validDateStart = null; db.DeptCollectionDetails.Find(deptID).validDateEnd = null; } else { return("Fail"); } db.SaveChangesAsync(); return("Success"); }