Ejemplo n.º 1
0
 public static BaseCharacteristicValue ConvertToViewModelIfExists(this BaseCharacteristicValue item)
 {
     if (item is NumberCharacteristicValue)
     {
         return(Mapper.CreateInstanceAndMapProperties <NumberCharacteristicValue>(item));
     }
     if (item is StringCharacteristicValue)
     {
         return(Mapper.CreateInstanceAndMapProperties <StringCharacteristicValue>(item));
     }
     return(item);
 }
Ejemplo n.º 2
0
        protected async Task <HttpResponseMessage> UpdateInner(BaseCharacteristicValue value)
        {
            try
            {
                await _dbContext.CharacteristicValueDbSetManager.UpdateAsync(value);

                return(Request.CreateResponse(HttpStatusCode.OK, value));
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex));
            }
        }
 private void ValidateDateInterval(BaseCharacteristicValue value)
 {
     if (value.IsTimeIntervalValue)
     {
         if (!value.CreationDate.HasValue || !value.EndCreationDate.HasValue)
         {
             throw new ArgumentException("Begin or end date value is missing for interval");
         }
         if (value.CreationDate > value.EndCreationDate)
         {
             throw new ArgumentException("Begin date cannot be greater than end date in interval");
         }
     }
 }
 public override Task UpdateAsync(BaseCharacteristicValue entity)
 {
     ValidateDateInterval(entity);
     return(base.UpdateAsync(entity));
 }