public IActionResult Put(int id, [FromBody] MentorTechnology mentortech) { if (ModelState.IsValid && id == mentortech.Id) { bool result = repository.UpdateMentorTechnology(mentortech); if (result) { return(Ok()); } return(StatusCode(StatusCodes.Status500InternalServerError)); } return(BadRequest(ModelState)); }
public IActionResult Post([FromBody] MentorTechnology mentortech) { if (ModelState.IsValid) { bool result = repository.AddMentorTechnology(mentortech); if (result) { return(Created("AddMentorTechnology", mentortech.Id)); } return(StatusCode(StatusCodes.Status500InternalServerError)); } return(BadRequest(ModelState)); }
public bool UpdateMentorTechnology(MentorTechnology mentortech) { try { context.MentorTechnologies.Update(mentortech); int result = context.SaveChanges(); if (result > 0) { return(true); } return(false); } catch (Exception ex) { throw; } }
public bool AddMentorTechnology(MentorTechnology mentortech) { try { context.MentorTechnologies.Add(mentortech); int result = context.SaveChanges(); if (result == 1) { return(true); } return(false); } catch (Exception) { throw; } }