public string Update(SubscriptionUpdateDTO subscription)
        {
            // Processing Phase
            try
            {
                using (var dbContextScope = _dbContextScopeFactory.Create())
                {
                    var result = _repositoryFactory.Get <ISubscriptionRepository>().FindById(subscription.Id);
                    if (result == null)
                    {
                        throw new NotFoundException("Subscription with provided id was not found.");
                    }

                    // Mapping Phase
                    subscription.ToDomainEntity(result);

                    _repositoryFactory.Get <ISubscriptionRepository>().Update(result);
                    dbContextScope.SaveChanges();
                }

                return(subscription.Id);
            }
            catch (Exception e)
            {
                throw GetExceptionResponse(e);
            }
        }
示例#2
0
 public IHttpActionResult Put(string id, [FromBody] SubscriptionUpdateDTO subscription)
 {
     try
     {
         subscription.Id = id;
         return(Ok(_subscriptionService.Update(subscription)));
     }
     catch (Exception e)
     {
         return(GetExceptionResponse(e));
     }
 }
 public string Update(SubscriptionUpdateDTO subscription)
 {
     return(Channel.Update(subscription));
 }