protected override IServiceMeasureDto Create(int performingUserId, IServiceMeasureDto entity)
 {
     using (var context = new PrometheusContext())
     {
         var measure = context.ServiceMeasures.Find(entity.Id);
         if (measure != null)
         {
             throw new InvalidOperationException(string.Format("Service Measure with ID {0} already exists.", entity.Id));
         }
         var savedMeasure = context.ServiceMeasures.Add(ManualMapper.MapDtoToServiceMeasure(entity));
         context.SaveChanges(performingUserId);
         return(ManualMapper.MapServiceMeasureToDto(savedMeasure));
     }
 }
 protected override IServiceMeasureDto Update(int performingUserId, IServiceMeasureDto entity)
 {
     using (var context = new PrometheusContext())
     {
         if (!context.ServiceMeasures.Any(x => x.Id == entity.Id))
         {
             throw new InvalidOperationException(
                       string.Format("Service Measure with ID {0} cannot be updated since it does not exist.", entity.Id));
         }
         var updatedServiceMeasure = ManualMapper.MapDtoToServiceMeasure(entity);
         context.ServiceMeasures.Attach(updatedServiceMeasure);
         context.Entry(updatedServiceMeasure).State = EntityState.Modified;
         context.SaveChanges(performingUserId);
         return(ManualMapper.MapServiceMeasureToDto(updatedServiceMeasure));
     }
 }