public async Task <long> Create(AddOrderVMRequest entity) { var response = await _httpService.Post2 <AddOrderVMRequest, long>(url, entity); if (!response.Success) { throw new ApplicationException(await response.GetBody()); } return(response.Response); }
public async Task <ActionResult> Post(AddOrderVMRequest entity) { #region Start the watch var watch = new Stopwatch(); watch.Start(); #endregion var result = await _entityServices.Post(entity, User.Identity.Name); #region End the watch watch.Stop(); result.Meta.TotalProcessingTime = watch.ElapsedMilliseconds; #endregion return(Ok(result)); }
public async Task <ApiResponse> Post(AddOrderVMRequest entity, string userName) { try { Order order = new() { UserCId = (await _userCServices.GetCurrent(userName)).Id, ProductId = entity.ProductId, OrderDate = DateTime.UtcNow, Quantity = entity.Quantity, Total = entity.Total, StorePaymentMethodId = entity.StorePaymentMethodId }; var newEntity = await _entityRepository.InsertAsync(order); return(ApiResponse.Create(HttpStatusCode.OK, newEntity.Id)); } catch (Exception) { return(ApiResponse.Create(HttpStatusCode.InternalServerError, null, "InternalServerError_Error")); } }