public async Task <IActionResult> Create(Employee employee) { if (!ModelState.IsValid) { return(View(employee)); } var result = await _clientHelper.PostClient("api/Employees", employee, ClaimsHelper.GetJwtToken(User)); if (result.StatusCode == System.Net.HttpStatusCode.Created) { return(RedirectToAction("Index")); } return(View(employee)); }
public async Task <IActionResult> Edit(TimeRecord timeRecord) { if (!ModelState.IsValid) { return(View(timeRecord)); } var result = await _clientHelper.PutClient <TimeRecord>($"api/TimeRecords/{timeRecord.TimeRecordID}", timeRecord, ClaimsHelper.GetJwtToken(User)); if (result.StatusCode == System.Net.HttpStatusCode.NoContent) { return(RedirectToAction("Index")); } else { return(View(timeRecord)); } }
public async Task <IActionResult> Edit(int id) { var emp = await _clientHelper.GetClient <IEnumerable <Employee> >("/api/Employees", null, ClaimsHelper.GetJwtToken(User)); ViewData["UserId"] = new SelectList(emp.Entity.ToList(), "EmployeeID", "FullName"); var result = await _clientHelper.GetClient <TimeRecord>("api/TimeRecords", "/" + id, ClaimsHelper.GetJwtToken(User)); if (result.StatusCode == System.Net.HttpStatusCode.OK) { return(View(result.Entity)); } else { return(View(new TimeRecord())); } }
public async Task <IActionResult> Create(TimeRecord timeRecort) { if (!ModelState.IsValid) { return(View(timeRecort)); } var result = await _clientHelper.PostClient("api/TimeRecords", timeRecort, ClaimsHelper.GetJwtToken(User)); if (result.StatusCode == System.Net.HttpStatusCode.Created) { return(RedirectToAction("Index")); } return(View(timeRecort)); }
public async Task <IActionResult> Create() { var result = await _clientHelper.GetClient <IEnumerable <Employee> >("/api/Employees", null, ClaimsHelper.GetJwtToken(User)); ViewData["UserId"] = new SelectList(result.Entity.ToList(), "EmployeeID", "FullName"); return(View()); }
public async Task <IActionResult> Index() { var result = await _clientHelper.GetClient <IEnumerable <TimeRecordViewModel> >("/api/TimeRecords", null, ClaimsHelper.GetJwtToken(User)); if (result == null) { ModelState.AddModelError("error", "Unable to retrieve record."); return(View(new List <TimeRecord>())); } if (result.StatusCode == System.Net.HttpStatusCode.OK) { result.Entity = result.Entity.OrderBy(o => o.StartDateTime).ToList(); return(View(result.Entity)); } else { return(View(new List <TimeRecord>())); } }
public async Task <IActionResult> Delete(int id) { var result = await _clientHelper.DeleteClient <TimeRecord>($"api/TimeRecords/{id}", ClaimsHelper.GetJwtToken(User)); if (result != null) { return(new JsonResult(new { success = true })); } return(new JsonResult(new { success = false })); }
public async Task <IActionResult> Edit(Employee employee) { if (!ModelState.IsValid) { return(View(employee)); } var result = await _clientHelper.PutClient <Employee>($"api/Employees/{employee.EmployeeID}", employee, ClaimsHelper.GetJwtToken(User)); if (result.StatusCode == System.Net.HttpStatusCode.NoContent) { return(RedirectToAction("Index")); } else { return(View(employee)); } }
public async Task <IActionResult> Edit(int id) { var result = await _clientHelper.GetClient <Employee>("api/Employees", "/" + id, ClaimsHelper.GetJwtToken(User)); if (result.StatusCode == System.Net.HttpStatusCode.OK) { return(View(result.Entity)); } else { return(View(new Employee())); } }
public async Task <IActionResult> Index() { var result = await _clientHelper.GetClient <IEnumerable <Employee> >("/api/Employees", null, ClaimsHelper.GetJwtToken(User)); if (result == null) { ModelState.AddModelError("error", "Unable to retrieve record."); return(View(new List <Employee>())); } if (result.StatusCode == System.Net.HttpStatusCode.OK) { return(View(result.Entity)); } else { return(View(new List <Employee>())); } }
public async Task <IActionResult> Details(int id) { var employee = await _clientHelper.GetClient <NetCoreModels.Employee>($"/api/Employees/{id}", null, ClaimsHelper.GetJwtToken(User)); if (employee == null) { return(NotFound()); } var result = await _clientHelper.GetClient <IEnumerable <TimeRecord> >($"/api/TimeRecords/EmployeeTimeRecord/{id}", null, ClaimsHelper.GetJwtToken(User)); var model = new EmployeeDetailsViewModel { Employee = employee.Entity, TimeRecords = result.Entity.OrderByDescending(o => o.StartDateTime).ToList() }; return(View(model)); }