//TODO: Change 1 and 0 responses to appropiate understantable values public int DeleteEmployee(int id) { Employee employee = db.Employees.Find(id); if (employee == null) { return(0); } db.Employees.Remove(employee); db.SaveChanges(); return(1); }
public int UpdateSkill(int id, SkillModel skill) { //TODO: Double check if there is a requirement to map EmployeeModel to Employee entity for updating using EF db.Entry(skill).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!SkillExists(id)) { return(404); } else { throw; } } return(200); }
public void Post([FromBody] ContactFormData contactFormData) { //ADD LAYER BETWEEN CONTROLLER AND EF? var test = contactFormData; var testInfo = new ContactFormData("Alonso", 29, DateTime.Now); using (var db = new AlexaGorillas_dbEntities()) { //VALIDATE INFO //IF GOOD SAVE / IF NOT THEN RETURN ERROR TO CLIENT db.ContactForms.Add(new ContactForm { FirstName = testInfo.FirstName, Age = testInfo.Age, Date = testInfo.Date, DayOfTheWeek = "Monday", Gender = "Male" }); db.SaveChanges(); } }