Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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;
        }