public async Task <IActionResult> UpdateRecord(RecordWriteDtoModel model) { // we can use auto mapper to map internal model to dto var entity = _recordRepository.Get(model.RecordId); if (entity == null) { return(NotFound()); } entity.Bill = model.Bill; entity.Description = model.Description; entity.DiseaseName = model.DiseaseName; entity.PatientId = model.PatientId; entity.TimeOfEntry = model.TimeOfEntry; _recordRepository.Update(entity); if (_recordRepository.SaveChanges()) { return(Ok(new { message = "Record updated successfully." })); } return(BadRequest()); }
public async Task <IActionResult> CreateRecord(RecordWriteDtoModel model) { // map Dto model to Internal Model , We can Use auto mapper packeges RecordModel entity = new RecordModel { Bill = model.Bill, Description = model.Description, DiseaseName = model.DiseaseName, PatientId = model.PatientId, TimeOfEntry = model.TimeOfEntry }; _recordRepository.Add(entity); if (_recordRepository.SaveChanges()) { return(Ok(new { message = "Record added successfully." })); } return(BadRequest()); }