public bool AddIntern(InternRequest requestIntern) { this.internRepository.Create(new Interns() { Name = requestIntern.Name, EmailId = requestIntern.EmailId, PhoneNo = requestIntern.PhoneNo, CreatedDate = DateTime.Now }); this.internRepository.Save(); return(true); }
public bool UpdateIntern(int id, InternRequest internRequest) { if (id == internRequest.Id) { Interns intern = new Interns() { InternsId = id, Name = internRequest.Name, EmailId = internRequest.EmailId, PhoneNo = internRequest.PhoneNo, CreatedDate = internRequest.CreatedDate }; this.internRepository.Update(intern); this.internRepository.Save(); return(true); } return(false); }
public IActionResult Put(int id, [FromBody] InternRequest requestIntern) { try { var response = internService.UpdateIntern(id, requestIntern); if (response == true) { return(Ok(response)); } else { return(BadRequest()); } } catch (Exception ex) { logger.Error(ex); throw; } }
public IActionResult Post(InternRequest requestIntern) { try { var response = internService.AddIntern(requestIntern); if (response == true) { return(Ok(response)); } else { return(BadRequest()); } } catch (Exception ex) { logger.Error(ex); throw; } }