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> PostUserProfile(EmployerHistoryVM EmployerHistory) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.EmployerHistories.Add(ConvertToDBModel(EmployerHistory)); await db.SaveChangesAsync(); return(CreatedAtRoute("DefaultApi", new { id = EmployerHistory.ID }, EmployerHistory)); }
private EmployerHistory ConvertToDBModel(EmployerHistoryVM eh) { return(new EmployerHistory { 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 }); }