public ActionResult StageForm(Stage stage) { try { using (var context = new HRMSContext()) { context.Stages.Add(stage); context.SaveChanges(); //get last sequence var idKey = (from c in context.Stages // the table1 here has red line under it. orderby c.Seq descending select c).First(); int last = idKey.Seq; Stage s = _db.Stages.SingleOrDefault(i => i.StageID == stage.StageID); s.Seq = last + 1; _db.SaveChanges(); } TempData["color"] = "green"; TempData["result"] = "Successfully Saved New Stage Record Database."; } catch (Exception ex) { TempData["color"] = "red"; TempData["result"] = ex.Message; } return(RedirectToAction("Stage")); }
public ActionResult UpdateStageSeq(Stage stage, string seq) { using (var _db = new HRMSContext()) { //update all sequence value to 0 string[] sq = seq.Split(','); foreach (var item in sq) { int q = Convert.ToInt32(item); Stage s = _db.Stages.SingleOrDefault(i => i.StageID == q); s.Seq = 0; _db.SaveChanges(); } foreach (var item in sq) { int q = Convert.ToInt32(item); Stage s = _db.Stages.SingleOrDefault(i => i.StageID == q); //get last sequence var idKey = (from c in _db.Stages // the table1 here has red line under it. orderby c.Seq descending select c).First(); int last = idKey.Seq; s.Seq = last + 1; _db.SaveChanges(); } } //update seq field to 1,2,3... so on and so forth return(RedirectToAction("Stage")); }
public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context) { HRMSContext db = new HRMSContext(); var user = db.EmployeeLogins.Where(d => d.Email == context.UserName).FirstOrDefault(); if (user != null && !string.IsNullOrEmpty(user.Email) && !string.IsNullOrEmpty(user.UserPassword)) { var identity = new ClaimsIdentity(context.Options.AuthenticationType); if (context.UserName == user.Email && context.Password == user.UserPassword) { identity.AddClaim(new Claim(ClaimTypes.Role, user.UserRole)); identity.AddClaim(new Claim("username", user.Email)); identity.AddClaim(new Claim(ClaimTypes.Name, user.UserName)); var uid = new Dictionary <string, string>() { { "userid", user.loginId.ToString() }, { "role", user.UserRole.ToString() } }; var ticket = new AuthenticationTicket(identity, new AuthenticationProperties(uid)); context.Validated(ticket); } else { context.SetError("invalid_grant", "Username and Password Combination Provided is Incorrect!"); return; } } }
public ActionResult Create(Candidate candidate) { try { using (var context = new HRMSContext()) { candidate.CreatedDate = DateTime.Now; context.Candidates.Add(candidate); context.SaveChanges(); //upload candidate's resume //drops database and data with it //Database.SetInitializer<CandidateContext>(new DropCreateDatabaseAlways<CandidateContext>()); if (Request.Files["cvfile"].ContentLength > 0) { //get last insert id for saving the resume string filename = candidate.Firstname + "_" + candidate.Lastname + "_" + candidate.CandidateID; string extension = System.IO.Path.GetExtension(Request.Files["cvfile"].FileName); string path = string.Format("{0}/{1}{2}", Server.MapPath("~/Documents/cv"), filename, extension); if (System.IO.File.Exists(path)) { System.IO.File.Delete(path); } Request.Files["cvfile"].SaveAs(path); Candidate c = _db.Candidates.SingleOrDefault(i => i.CandidateID == candidate.CandidateID); c.CVFilename = filename; _db.SaveChanges(); } else { candidate.CVFilename = ""; } } TempData["color"] = "green"; TempData["result"] = "Successfully Saved New Candidate To Database."; return(RedirectToAction("Index")); } catch (Exception ex) { ViewBag.Alert = ex.Message; return(View()); } }
public ActionResult Update(Candidate candidate, int id) { using (var _db = new HRMSContext()) { Candidate c = _db.Candidates.SingleOrDefault(i => i.CandidateID == id); c.Firstname = candidate.Firstname; c.Lastname = candidate.Lastname; c.Title = candidate.Title; c.Email = candidate.Email; c.Telephone = candidate.Telephone; c.Status = candidate.Status; c.ShortDesc = candidate.ShortDesc; if (Request.Files["cvfile"].ContentLength > 0) { //get last insert id for saving the resume string filename = candidate.Firstname + "_" + candidate.Lastname + "_" + id; string extension = System.IO.Path.GetExtension(Request.Files["cvfile"].FileName); string path = string.Format("{0}/{1}{2}", Server.MapPath("~/Documents/cv"), filename, extension); if (System.IO.File.Exists(path)) { System.IO.File.Delete(path); } Request.Files["cvfile"].SaveAs(path); candidate.CVFilename = filename + "." + extension; } else { candidate.CVFilename = ""; } c.CVFilename = candidate.CVFilename; _db.SaveChanges(); TempData["color"] = "green"; TempData["result"] = "Successfully Updated Candidate Record."; } return(RedirectToAction("Index")); }
public ActionResult Create(Opening opening) { try { using (var context = new HRMSContext()) { opening.CreatedDate = DateTime.Now; context.Openings.Add(opening); context.SaveChanges(); } } catch (Exception ex) { TempData["color"] = "red"; TempData["result"] = ex.Message; } return(new RedirectResult(Url.Action("Hire", new { id = opening.OpeningID }) + "?#tabs-2")); }
public ActionResult UpdateStage(Stage stage, int id) { using (var _db = new HRMSContext()) { Stage s = _db.Stages.SingleOrDefault(i => i.StageID == id); //get last sequence var idKey = (from c in _db.Stages // the table1 here has red line under it. orderby c.Seq descending select c).First(); int last = idKey.Seq; s.Desc = stage.Desc; _db.SaveChanges(); TempData["color"] = "green"; TempData["result"] = "Successfully Updated Candidate Record."; } return(RedirectToAction("Stage")); }
public DependentController(HRMSContext context) { _context = context; }
public EmployeeController(HRMSContext context) { _context = context; }
public EmployeeBenifitCostController(HRMSContext context) { _context = context; }