public IActionResult PutAllergy(ConsultationAllergy Allergy) { try { var existingAllergy = _context.consultation_allergy.Where(s => s.Id == Allergy.Id) .FirstOrDefault(); if (existingAllergy != null) { existingAllergy.remarks = Allergy.remarks; _context.SaveChanges(); } else { return(NotFound()); } return(Ok()); } catch (Exception ex) { //_logger.LogError($"Something went wrong inside CreateOwner action: {ex.Message}"); return(StatusCode(500, "Internal server error")); } }
public IActionResult PostAllergy([FromBody] ConsultationAllergy Allergy) { try { if (Allergy == null) { // _logger.LogError("Owner object sent from client is null."); return(BadRequest("Owner object is null")); } if (!ModelState.IsValid) { //_logger.LogError("Invalid owner object sent from client."); return(BadRequest("Invalid model object")); } // var ownerEntity = _mapper.Map<Owner>(owner); _context.consultation_allergy.Add(Allergy); _context.SaveChanges(); // var createdOwner = _mapper.Map<OwnerDto>(ownerEntity); //return CreatedAtRoute("OwnerById", new { id = Allergy.Id }, Allergy); return(StatusCode(201, "Created successfully")); } catch (Exception ex) { //_logger.LogError($"Something went wrong inside CreateOwner action: {ex.Message}"); return(StatusCode(500, "Internal server error")); } }