public async Task <IHttpActionResult> PutEmployerHistory(int id, EmployerHistoryVM EmployerHistoryVM) { EmployerHistory EmployerHistory = ConvertToDBModel(EmployerHistoryVM); if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != EmployerHistory.ID) { return(BadRequest()); } db.Entry(EmployerHistory).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EmployerHistoryExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IHttpActionResult> GetUserProfile(int id) { EmployerHistory employerHistory = await db.EmployerHistories.FindAsync(id); if (employerHistory == null) { return(NotFound()); } return(Ok(ConvertToViewModel(employerHistory))); }
public async Task <IHttpActionResult> DeleteEmployerHistory(int id) { EmployerHistory EmployerHistory = await db.EmployerHistories.FindAsync(id); if (EmployerHistory == null) { return(NotFound()); } db.EmployerHistories.Remove(EmployerHistory); await db.SaveChangesAsync(); return(Ok(ConvertToViewModel(EmployerHistory))); }
private EmployerHistoryVM ConvertToViewModel(EmployerHistory eh) { return(new EmployerHistoryVM { ID = eh.ID, LoginID = eh.LoginID, EmployerName = eh.EmployerName, IsCurrent = eh.IsCurrent, FromMonth = eh.FromMonth, FromYear = eh.FromYear, ToMonth = eh.ToMonth, ToYear = eh.ToYear, Designation = eh.Designation, TeamSize = eh.TeamSize, JobProfile = eh.JobProfile, NoticePeriod = eh.NoticePeriod, DisplayOrder = eh.DisplayOrder, UpdatedOn = eh.UpdatedOn }); }