// GET: Employer/Edit/5 public async Task <ActionResult> Edit(string id) { var employer = await EmployerLib.GetEmployer(id.ToString()); if (employer == null) { var errorMsg = string.Format("Employer {0} not found.", id); throw new HttpException(404, errorMsg); } return(View(employer)); }
public async Task <ActionResult> Delete(string id, FormCollection collection) { try { await EmployerLib.DeleteEmployer(id); return(RedirectToAction("Index")); } catch { return(View()); } }
public async Task <ActionResult> Edit(string id, FormCollection collection) { try { var employerName = collection["EmployerName"].ToString(); var employer = new Employer() { Id = id, EmployerName = employerName }; await EmployerLib.UpdateEmployer(employer); return(RedirectToAction("Index")); } catch (Exception ex) { return(View()); } }
public async Task <ActionResult> Create(FormCollection collection) { try { var rand = new Random(); var id = rand.Next().ToString(); var employerName = collection["EmployerName"].ToString(); var employer = new Employer() { Id = id, EmployerName = employerName }; await EmployerLib.InsertEmployer(employer); return(RedirectToAction("Index")); } catch (Exception ex) { return(View()); } }
// GET: Employer public async Task <ActionResult> Index() { var employers = await EmployerLib.GetAllEmployers(); return(View(employers)); }