public bool UpdateTech(UpdateTechDTO updatedTechDTO) { try { var updatedTech = new Technology { TechId = updatedTechDTO.TechId, Name = updatedTechDTO.Name, Description = updatedTechDTO.Description, ImgSourceLink = updatedTechDTO.ImgSourceLink, BasicFee = updatedTechDTO.BasicFee, Commission = updatedTechDTO.Commission, Duration = updatedTechDTO.Duration, Status = updatedTechDTO.Status }; context.Technologies.Update(updatedTech); int result = context.SaveChanges(); if (result > 0) { return(true); } return(false); } catch (Exception e) { throw; } }
public IActionResult Put(int id, [FromBody] UpdateTechDTO updatedTechDTO) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var result = repository.UpdateTech(updatedTechDTO); if (result) { return(Created("UpdateTech", new { Message = "Technology updated successfully", Data = updatedTechDTO })); } return(BadRequest(result)); }