public ActionResult NewEmployeeLookup() { ViewBag.WorkerIDHelp = PowerShell.GetHTMLString("NewHires", "WorkerIDHelp", null); ViewBag.HireTypeGuidelines = PowerShell.GetHTMLString("NewHires", "HireTypeGuidelines", null); return(View(NewHire.EmployeeHireTypes())); }
public ActionResult NewEmployeeLookup(string workerId, string hireType) { ViewBag.WorkerIDHelp = PowerShell.GetHTMLString("NewHires", "WorkerIDHelp", null); ViewBag.HireTypeGuidelines = PowerShell.GetHTMLString("NewHires", "HireTypeGuidelines", null); if (String.IsNullOrWhiteSpace(workerId)) { ModelState.AddModelError("WorkerID", "Worker ID Required"); return(View(NewHire.EmployeeHireTypes())); } NewHire employee = NewHire.EmployeeLookup(workerId, hireType, db); if (employee == null) { ModelState.AddModelError("WorkerID", "Workday Lookup Error"); return(View(NewHire.EmployeeHireTypes())); } if (employee.EmailAddress == null) { employee.SetEmailAddress(); } ViewBag.Countries = db.Countries.Select(x => x.Name).Distinct(); ViewBag.Offices = Office.GetOfficeNames(employee.Country, db); ViewBag.O365Profiles = O365Profile.GetSelectList(); ViewBag.O365ProfileDetails = PowerShell.GetHTMLString("NewHires", "O365ProfileDetails", null); return(View("NewEmployee", employee)); }
public IHttpActionResult SendNewHireServiceRequest(NewHire newHire) { try { ServiceRequest serviceRequest = ServiceRequest.NewHire(newHire, db); if (serviceRequest != null) { Mailer mailer = new Mailer(MessageTemplate.ServiceRequest, false); if (newHire.ITaaS == true) { mailer = new Mailer(MessageTemplate.ITAASRequest, false); } mailer.SetFromAddress(newHire.ManagersEmail); mailer.SendMessage("ServiceRequest", serviceRequest, serviceRequest.Subject); return(StatusCode(HttpStatusCode.NoContent)); } return(BadRequest()); } catch (Exception) { return(BadRequest()); } }
public IHttpActionResult PutNewHire(int id, NewHire newHire) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != newHire.ID) { return(BadRequest()); } db.Entry(newHire).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!NewHireExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public ActionResult DeleteConfirmed(int id) { NewHire newHire = db.NewHires.Find(id); NewHireNotice newHireNotice = new NewHireNotice(newHire, "Cancel"); if (TryValidateModel(newHireNotice) == true) { Mailer mailer = new Mailer(MessageTemplate.NewHireEmployee, true); if (newHire.IsContingent == true) { mailer = new Mailer(MessageTemplate.NewHireContingent, true); } mailer.SetFromAddress(newHire.RequestersEmail); mailer.AddRecipient(newHire.ManagersEmail); mailer.SendMessage("NewHireNotice", newHireNotice, newHireNotice.Subject); db.NewHires.Remove(newHire); db.SaveChanges(); return(RedirectToAction("Index")); } ModelState.AddModelError("MailNotice", "Mail Notice Error"); return(View()); }
protected void btnApprv_Click(object sender, EventArgs e) { try { AppUser usr = null; if (Session["user"] != null) { usr = (AppUser)Session["user"]; } else { Response.Redirect("../Login.aspx", false); return; } bool isset = false; foreach (GridViewRow row in gvDept.Rows) { if (((CheckBox)row.FindControl("chkRow")).Checked) { Label lbID = row.FindControl("lbRecID") as Label; int recID = int.Parse(lbID.Text); NewHire exStf = CommonBLL.GetNewHire(recID); if (exStf != null && exStf.Status == (int)Utility.BudgetItemStatus.Pending_Approval) { exStf.Status = (int)Utility.BudgetItemStatus.Approved; exStf.ApprovedBy = usr.FullName; exStf.DateApproved = DateTime.Now; CommonBLL.UpdateNewHire(exStf); isset = true; } } } if (isset) { BindGrid(); success.Visible = true; success.InnerHtml = "<button type='button' class='close' data-dismiss='alert'>×</button>Selected Record(s) has been successfully approved."; return; } else { BindGrid(); error.Visible = true; error.InnerHtml = " <button type='button' class='close' data-dismiss='alert'>×</button> An error occured some of selected record(s) could not be approved.If error persist contact Administrator!!."; } } catch (Exception ex) { error.Visible = true; error.InnerHtml = " <button type='button' class='close' data-dismiss='alert'>×</button> An error occured. Kindly try again. If error persist contact Administrator!!."; Utility.WriteError("Error: " + ex.InnerException); } }
public IHttpActionResult DeleteNewHire(int id) { NewHire newHire = db.NewHires.Find(id); if (newHire == null) { return(NotFound()); } db.NewHires.Remove(newHire); db.SaveChanges(); return(Ok(newHire)); }
public ActionResult NewHireFix(NewHire newHire) { if (ModelState.IsValid) { newHire.ErrorLog = null; db.Entry(newHire).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("NewHireErrors")); } return(View(newHire)); }
public ActionResult NewHireFix(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } NewHire newHire = db.NewHires.Find(id); if (newHire == null) { return(HttpNotFound()); } return(View(newHire)); }
public ActionResult NewEmployee(NewHire employee) { employee.ValidateEmployee(ModelState, User); //if (db.NewHires.Any(x => x.WorkerID == employee.WorkerID)) //{ // ModelState.AddModelError("Request", String.Format("{0} Already Requested", employee.HireType)); //} if (ModelState.IsValid) { NewHireNotice newHireNotice = new NewHireNotice(employee, "New"); if (TryValidateModel(newHireNotice) == true) { if (employee.Suppress == false) { Mailer mailer = new Mailer(MessageTemplate.NewHireEmployee, true); mailer.SetFromAddress(employee.RequestersEmail); mailer.AddRecipient(employee.ManagersEmail); if (employee.ITaaS == true) { mailer.AddITaaSNotificationGroup(); } mailer.SendMessage("NewHireNotice", newHireNotice, newHireNotice.Subject); } db.NewHires.Add(employee); db.SaveChanges(); return(RedirectToAction("Index")); } ModelState.AddModelError("MailNotice", "Mail Notice Error"); } ViewBag.Countries = db.Countries.Select(x => x.Name).Distinct(); ViewBag.Offices = Office.GetOfficeNames(employee.Country, db); ViewBag.O365Profiles = O365Profile.GetSelectList(); ViewBag.O365ProfileDetails = PowerShell.GetHTMLString("NewHires", "O365ProfileDetails", null); return(View(employee)); }
public ActionResult NewContingent() { NewHire contingent = NewHire.Contingent(); if (contingent == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ViewBag.Countries = db.Countries.Select(x => x.Name).Distinct(); ViewBag.Offices = Office.GetOfficeNames(contingent.Country, db); ViewBag.O365Profiles = O365Profile.GetSelectList(); ViewBag.O365ProfileDetails = PowerShell.GetHTMLString("NewHires", "O365ProfileDetails", null); return(View(contingent)); }
public ActionResult Edit(int id, NewHire newHire) { newHire.ValidateManager(ModelState); newHire.SetRequestersEmail(User); newHire.SetServiceDate(); if (ModelState.IsValid) { NewHireNotice newHireNotice = new NewHireNotice(newHire, "Update"); if (TryValidateModel(newHireNotice) == true) { if (newHire.Suppress == false) { Mailer mailer = new Mailer(MessageTemplate.NewHireEmployee, true); if (newHire.IsContingent == true) { mailer = new Mailer(MessageTemplate.NewHireContingent, true); } mailer.SetFromAddress(newHire.RequestersEmail); mailer.AddRecipient(newHire.ManagersEmail); if (newHire.ITaaS == true) { mailer.AddITaaSNotificationGroup(); } mailer.SendMessage("NewHireNotice", newHireNotice, newHireNotice.Subject); } db.Entry(newHire).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ModelState.AddModelError("MailNotice", "Mail Notice Error"); } ViewBag.Countries = db.Countries.Select(x => x.Name).Distinct(); ViewBag.Offices = Office.GetOfficeNames(newHire.Country, db); return(View(newHire)); }
internal static AccountDetails NewHire(NewHire newHire) { try { AccountDetails accountDetails = new AccountDetails(); accountDetails.Name = String.Format("{0} {1}", newHire.FirstName, newHire.LastName); accountDetails.Subject = String.Format("{0} Update | {1} | {2}", newHire.HireType, accountDetails.Name, newHire.StartDate.ToString("MMMM dd, yyyy")); accountDetails.EmailAddress = newHire.EmailAddress; accountDetails.LogonName = newHire.LogonName; accountDetails.Password = newHire.Password; return(accountDetails); } catch (Exception) { return(null); } }
public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } NewHire newHire = db.NewHires.Find(id); if (newHire == null) { return(HttpNotFound()); } ViewBag.Countries = db.Countries.Select(x => x.Name).Distinct(); ViewBag.Offices = Office.GetOfficeNames(newHire.Country, db); return(View(newHire)); }
public NewHireNotice(NewHire newHire, string noticeType) { if (newHire.HireType == "New Employee" && newHire.WorkerType != "Employee-Regular") { if (newHire.WorkerType.Contains("Contractor")) { newHire.HireType = "New Contractor"; } else if (newHire.WorkerType.Contains("Intern") && !newHire.WorkerType.Contains("Temporary")) { newHire.HireType = "New Intern"; } } switch (noticeType) { case "Update": Heading = String.Format("{0} Notice Update", newHire.HireType); break; case "Cancel": Heading = String.Format("{0} Cancellation", newHire.HireType); break; default: case "New": Heading = String.Format("{0} Notice", newHire.HireType); break; } Name = String.Format("{0} {1}", newHire.FirstName, newHire.LastName); Type = newHire.WorkerType; StartDate = newHire.StartDate.ToString("MMMM dd, yyyy"); Title = newHire.Title; Department = newHire.Department; Manager = newHire.Manager; Office = newHire.Office; Notes = newHire.PublicNotes; Subject = String.Format("{0} | {1} | {2}", Heading, Name, StartDate); }
public IHttpActionResult SendNewHireAccountDetails(NewHire newHire) { try { AccountDetails accountDetails = AccountDetails.NewHire(newHire); if (accountDetails != null) { //Account Details Mailer mailer = new Mailer(MessageTemplate.Default, true); if (newHire.IsContingent == true) { mailer = new Mailer(MessageTemplate.Contingent, true); } mailer.AddRecipient(newHire.ManagersEmail); mailer.SendMessage("AccountDetails", accountDetails, accountDetails.Subject); //Password Notice mailer = new Mailer(MessageTemplate.Default, false); if (newHire.IsContingent == true) { mailer = new Mailer(MessageTemplate.Contingent, false); } mailer.AddRecipient(newHire.ManagersEmail); mailer.AddBcc("*****@*****.**"); mailer.SendMessage("PasswordNotice", accountDetails, accountDetails.Subject); return(StatusCode(HttpStatusCode.NoContent)); } return(BadRequest()); } catch (Exception) { return(BadRequest()); } }
public ActionResult NewContingent(NewHire contingent) { contingent.ValidateContingent(ModelState, User); if (db.NewHires.Any(x => x.FirstName == contingent.FirstName && x.LastName == contingent.LastName)) { ModelState.AddModelError("Request", String.Format("{0} Already Requested", contingent.HireType)); } if (ModelState.IsValid) { contingent.SetEmailAddress(); NewHireNotice newHireNotice = new NewHireNotice(contingent, "New"); if (TryValidateModel(newHireNotice) == true) { Mailer mailer = new Mailer(MessageTemplate.NewHireContingent, true); mailer.SetFromAddress(contingent.RequestersEmail); mailer.AddRecipient(contingent.ManagersEmail); mailer.SendMessage("NewHireNotice", newHireNotice, newHireNotice.Subject); db.NewHires.Add(contingent); db.SaveChanges(); return(RedirectToAction("Index")); } ModelState.AddModelError("MailNotice", "Mail Notice Error"); } ViewBag.Countries = db.Countries.Select(x => x.Name).Distinct(); ViewBag.Offices = Office.GetOfficeNames(contingent.Country, db); ViewBag.O365Profiles = O365Profile.GetSelectList(); ViewBag.O365ProfileDetails = PowerShell.GetHTMLString("NewHires", "O365ProfileDetails", null); return(View(contingent)); }
protected void gvDept_RowCommand(object sender, GridViewCommandEventArgs e) { try { if (e.CommandName == "del") { int index = int.Parse(e.CommandArgument.ToString()); // int key = Convert.ToInt32(gvDept.DataKeys[index].Value.ToString()); NewHire estf = CommonBLL.GetNewHire(index); CommonBLL.DeleteNewHire(estf); BindGrid(); success.Visible = true; success.InnerHtml = " <button type='button' class='close' data-dismiss='alert'>×</button> Record deleted successfully!!."; return; } if (e.CommandName == "edt") { hid.Value = "Update"; dvID.Visible = false; btnSubmit.Text = "Update"; //GridViewRow row = gvDept.SelectedRow; int index = int.Parse(e.CommandArgument.ToString()); NewHire estf = CommonBLL.GetNewHire(index); txtID.Text = estf.ID.ToString(); txtTot.Text = estf.TotalNumber.ToString(); ddlgrade.SelectedValue = estf.GradeID.ToString(); ddlMonth.SelectedValue = estf.MonthYear.ToString(); } } catch (Exception ex) { error.Visible = true; error.InnerHtml = "<button type='button' class='close' data-dismiss='alert'>×</button> An error occurred. kindly try again!!!"; Utility.WriteError("Error: " + ex.InnerException); } }
protected void btnReturn_Click(object sender, EventArgs e) { try { AppUser usr = null; if (Session["user"] != null) { usr = (AppUser)Session["user"]; } else { Response.Redirect("../Login.aspx", false); return; } if (string.IsNullOrEmpty(txtcomment.Text)) { modalErr.Visible = true; modalErr.InnerText = "Comment is required!!!"; mpeAppr.Show(); return; } bool isset = false; AppUser budgetInputer = new AppUser(); foreach (GridViewRow row in gvDept.Rows) { if (((CheckBox)row.FindControl("chkRow")).Checked) { Label lbID = row.FindControl("lbRecID") as Label; int recID = int.Parse(lbID.Text); NewHire exStf = CommonBLL.GetNewHire(recID); if (exStf != null && exStf.Status == (int)Utility.BudgetItemStatus.Approved) { exStf.Status = (int)Utility.BudgetItemStatus.Returned_For_Correction; CommonBLL.UpdateNewHire(exStf); budgetInputer = UserBLL.GetUserByUserName(exStf.AddedBy); isset = true; } } } if (isset) { BindGrid(); //sending mail string body = ""; string from = ConfigurationManager.AppSettings["exUser"].ToString(); string siteUrl = ConfigurationManager.AppSettings["siteUrl"].ToString(); string appLogo = ConfigurationManager.AppSettings["appLogoUrl"].ToString(); string hodEmail = UserBLL.GetApproverEmailByDept(budgetInputer.DepartmentID.Value); string subject = "Budget Item Correction Notification"; string FilePath = Server.MapPath("EmailTemplates/"); if (File.Exists(FilePath + "ReturnBudget.htm")) { FileStream f1 = new FileStream(FilePath + "ReturnBudget.htm", FileMode.Open); StreamReader sr = new StreamReader(f1); body = sr.ReadToEnd(); body = body.Replace("@add_appLogo", appLogo); body = body.Replace("@siteUrl", siteUrl); body = body.Replace("@BudgetElement", "New Hires"); body = body.Replace("@add_Comment", txtcomment.Text); //Replace the values from DB or any other source to personalize each mail. f1.Close(); } string rst = ""; try { rst = Utility.SendMail(budgetInputer.Email, from, hodEmail, subject, body); } catch { } if (rst.Contains("Successful")) { success.Visible = true; success.InnerHtml = "<button type='button' class='close' data-dismiss='alert'>×</button>Selected Record(s) has been successfully Returned for correction.Notification has been sent to Initiator"; return; } else { success.Visible = true; success.InnerHtml = "<button type='button' class='close' data-dismiss='alert'>×</button>Selected Record(s) has been successfully Returned for correction.Notification could NOT be sent at this time"; return; } } else { BindGrid(); error.Visible = true; error.InnerHtml = " <button type='button' class='close' data-dismiss='alert'>×</button> An error occured. Either no record is selected OR some of selected record(s) could not be approved.If error persist contact Administrator!!."; } } catch (Exception ex) { error.Visible = true; error.InnerHtml = " <button type='button' class='close' data-dismiss='alert'>×</button> An error occured. Kindly try again. If error persist contact Administrator!!."; Utility.WriteError("Error: " + ex.Message); } }
internal static ServiceRequest NewHire(NewHire newHire, SNAPContext db) { try { ServiceRequest serviceRequest = new ServiceRequest(); serviceRequest.Name = String.Format("{0} {1}", newHire.FirstName, newHire.LastName); serviceRequest.Title = newHire.Title; serviceRequest.Department = newHire.Department; serviceRequest.Manager = newHire.Manager; serviceRequest.Office = newHire.Office; serviceRequest.Notes = String.Format("{0}\n{1}", newHire.PublicNotes, newHire.PrivateNotes); Country country = db.Countries.Where(x => x.Name == newHire.Country).First(); string workerType = "#CONT"; if (newHire.WorkerType == "Employee-Regular") { workerType = "#FTE"; } string region = country.ISO2; if (newHire.ITaaS == true) { region = "ITAAS"; } serviceRequest.Subject = String.Format("AM.{0} SNAP New Hire | {1} | {2} | {3}", region, serviceRequest.Name, newHire.StartDate.ToString("MMMM dd, yyyy"), workerType); if (newHire.HireType == "Employee Transfer") { serviceRequest.Subject = String.Format("{0} {1}", serviceRequest.Subject, "#Transfer"); } switch (newHire.O365License) { case "E1": serviceRequest.Subject = String.Format("{0} {1}", serviceRequest.Subject, "#E1"); break; case "E1/Windows": serviceRequest.Subject = String.Format("{0} {1}", serviceRequest.Subject, "#Computer"); serviceRequest.Subject = String.Format("{0} {1}", serviceRequest.Subject, "#E1"); break; case "E3, EMS": serviceRequest.Subject = String.Format("{0} {1}", serviceRequest.Subject, "#Computer"); serviceRequest.Subject = String.Format("{0} {1}", serviceRequest.Subject, "#E3"); break; default: break; } if (newHire.PhoneRequired == true) { serviceRequest.Subject = String.Format("{0} {1}", serviceRequest.Subject, "#Phone"); } if (db.Offices.Any(o => o.Name == newHire.Office) == false) { serviceRequest.Subject = String.Format("{0} {1}", serviceRequest.Subject, "#Remote"); } if (newHire.Department.Contains("Managed Services") && newHire.Title.Contains("Engineer")) { serviceRequest.Subject = String.Format("{0} {1}", serviceRequest.Subject, "#GSC"); } if (newHire.Department.Contains("Solutions") || newHire.Department.Contains("PreSales")) { serviceRequest.Subject = String.Format("{0} {1}", serviceRequest.Subject, "#Solutions"); } return(serviceRequest); } catch (Exception) { return(null); } }
protected void btnSubmit_Click(object sender, EventArgs e) { NewHire stf = null; try { usr = (AppUser)Session["user"]; budYr = (BudgetYear)Session["budgetYr"]; Grade gd = LookUpBLL.GetGrade(int.Parse(ddlgrade.SelectedValue)); if (hid.Value == "Update") { bool rst = false; int tot = 0; int month = int.Parse(ddlMonth.SelectedValue); stf = CommonBLL.GetNewHire(Convert.ToInt32(txtID.Text)); if (stf != null) { if (!int.TryParse(txtTot.Text, out tot)) { error.Visible = true; error.InnerHtml = " <button type='button' class='close' data-dismiss='alert'>×</button>Total must be numeric!!."; return; } stf.TotalNumber = tot; stf.GradeID = int.Parse(ddlgrade.SelectedValue); stf.DepartmentID = usr.DepartmentID; stf.Status = (int)Utility.BudgetItemStatus.Pending_Approval; stf.MonthYear = month; if (gd != null) { stf.TotalCost = tot * gd.CostPerMonth * Utility.GetOutstandingMonth(month); } stf.BudgetYrID = budYr.ID; rst = CommonBLL.UpdateNewHire(stf); if (rst != false) { BindGrid(); success.Visible = true; success.InnerHtml = " <button type='button' class='close' data-dismiss='alert'>×</button> Record updated successfully!!."; return; } } else { error.Visible = true; error.InnerHtml = " <button type='button' class='close' data-dismiss='alert'>×</button>Record could Not updated. Kindly try again. If error persist contact Administrator!!."; } } else { int tot = 0; if (!int.TryParse(txtTot.Text, out tot)) { error.Visible = true; error.InnerHtml = " <button type='button' class='close' data-dismiss='alert'>×</button>Total must be numeric!!."; return; } bool result = false; stf = new NewHire(); int month = int.Parse(ddlMonth.SelectedValue); stf.GradeID = int.Parse(ddlgrade.SelectedValue); stf.DepartmentID = usr.DepartmentID; stf.AddedBy = User.Identity.Name; stf.DateAdded = DateTime.Now; stf.TotalNumber = tot; stf.BudgetYrID = budYr.ID; stf.MonthYear = int.Parse(ddlMonth.SelectedValue); stf.Status = (int)Utility.BudgetItemStatus.Pending_Approval; if (gd != null) { stf.TotalCost = tot * gd.CostPerMonth * Utility.GetOutstandingMonth(month); } result = CommonBLL.AddNewHire(stf); if (result) { BindGrid(); txtTot.Text = ""; ddlgrade.SelectedValue = ""; success.Visible = true; success.InnerHtml = " <button type='button' class='close' data-dismiss='alert'>×</button> Record added successfully!!."; return; } else { error.Visible = true; error.InnerHtml = " <button type='button' class='close' data-dismiss='alert'>×</button>Record could Not added. Kindly try again. If error persist contact Administrator!!."; } } } catch (Exception ex) { error.Visible = true; error.InnerHtml = "<button type='button' class='close' data-dismiss='alert'>×</button> An error occurred. kindly try again!!!"; Utility.WriteError("Error: " + ex.Message); } }