public UpdateMeasurementResponse Update(UpdateMeasurementRequest request) { var response = new UpdateMeasurementResponse(); try { var measurement = request.MapTo <Measurement>(); DataContext.Measurements.Attach(measurement); DataContext.Entry(measurement).State = EntityState.Modified; DataContext.SaveChanges(); response.IsSuccess = true; response.Message = "Measurement item has been updated successfully"; } catch (DbUpdateException dbUpdateException) { response.Message = dbUpdateException.Message; } return(response); }
public UpdateMeasurementResponse Update(UpdateMeasurementRequest request) { var response = new UpdateMeasurementResponse(); try { var measurement = request.MapTo<Measurement>(); DataContext.Measurements.Attach(measurement); DataContext.Entry(measurement).State = EntityState.Modified; DataContext.SaveChanges(); response.IsSuccess = true; response.Message = "Measurement item has been updated successfully"; } catch (DbUpdateException dbUpdateException) { response.Message = dbUpdateException.Message; } return response; }