public Task <Common.Entity.Result <int> > Update(Common.Entity.Client client)
        {
            Common.Entity.Result <int> result = new Common.Entity.Result <int> {
            };
            try
            {
                using (var context = new BillingContext())
                {
                    ////truncate table
                    context.Client.RemoveRange(context.Client);
                    Log.Info($"Commercial transactions have been deleted in the database....");

                    ////insert new values
                    context.Client.Add(client);
                    context.SaveChanges();
                    Log.Info($"new transactions were inserted....");
                }
            }
            catch (Exception ex)
            {
                result.StatusCode = System.Net.HttpStatusCode.InternalServerError;
                Log.Exception(ex, $"{GetType().FullName}.Update");
            }
            return(Task.FromResult(result));
        }
Exemple #2
0
 public async Task <Common.Entity.Result <int> > Update(Common.Entity.Client client)
 {
     Common.Entity.Result <int> result = new Common.Entity.Result <int> {
     };
     try
     {
         result = await ClientService.Update(client);
     }
     catch (Exception ex)
     {
         result.StatusCode = System.Net.HttpStatusCode.InternalServerError;
         Log.Exception(ex, $"{GetType().FullName}.Update");
     }
     return(await Task.FromResult(result));
 }
        // PUT: api/client
        public async Task <IHttpActionResult> Put(Common.Entity.Client client)
        {
            var response = await ClientService.Update(client);

            return(Content(response.StatusCode, response.Data));
        }