public async Task HandleAsync(ProductPurchasedEvent @event) { var shippingInvoice = new ShippingInvoice(@event.PurchaseOrderNo, @event.BuyerId, @event.PurchaseOrderList, @event.ShippingAddress); _shippingInvoiceRepository.Add(shippingInvoice); await _unitOfWork.SaveChangesAsync(); }
protected TData Add(TData data) { var entity = GetEntityObject(data); entity = _repository.Add(entity); return(GetDataObject(entity)); }
public ProductCategoryViewModel Add(ProductCategoryViewModel productCategoryVm) { var productCategory = _mapper.Map <ProductCategoryViewModel, ProductCategory>(productCategoryVm); _productCategoryRepository.Add(productCategory); return(productCategoryVm); }
public async Task HandleAsync(CreatePurchaseOrderCommand command) { //Issue: Crossing the boundary context to cut shot the time. //This should call the Basket Api and get the details. Not the repository directly. var basketSpecification = new BasketWithItemsSpecification(command.BasketId); var basket = await _basketAsyncRepository.GetSingleAsync(basketSpecification); var items = new List <PurchaseOrderItem>(); foreach (var basketItem in basket.BasketItems) { var catalogItem = await _catalogItemAsyncRepository.GetByIdAsync(basketItem.CatalogItemId); var itemOrdered = new CatalogItemOrdered(catalogItem.Id, (CatalogItemType)catalogItem.CatalogType, catalogItem.Name, catalogItem.PictureUri); var orderItem = new PurchaseOrderItem(itemOrdered, basketItem.UnitPrice, basketItem.Quantity); items.Add(orderItem); } var purchaseOrderId = Guid.NewGuid(); var purchaseOrderIdNumberMapping = new PurchaseOrderIdNumberMapping { PurchaseOrderId = purchaseOrderId }; _purchaseOrderIdNumberMappingAsyncRepository.Add(purchaseOrderIdNumberMapping); await _unitOfWork.SaveChangesAsync(); var purchaseOrder = new Domain.PurchaseOrder(purchaseOrderId, purchaseOrderIdNumberMapping.Id, basket.BuyerId, command.Address, items); await _shopAggregateRepositoryService.SaveAsync(purchaseOrder); }
public async Task <ContentResult> CaptureOrder([FromQuery] string token, [FromQuery] string payerid) { //return $"{token}:{payerid}"; string bearerToken = await Helper.getAccessToken(_clientFactory, _configRoot); String uri = string.Format(_configRoot.Paypal_capture_payment_url, token); HttpRequestMessage request = new HttpRequestMessage { Method = HttpMethod.Post, // RequestUri = new Uri($"https://api.sandbox.paypal.com/v2/checkout/orders/{token}/capture"), RequestUri = new Uri(uri), //this really suck, took me a whole day => HttpRequestMessage prevented me add content-type for httpclient post with NO content. //I tried all => only work with empty string Content = new StringContent("", Encoding.UTF8, "application/json") }; request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", bearerToken); var client = _clientFactory.CreateClient(); _logger.LogInformation("About to Request capture order"); var response = await client.SendAsync(request); if (response.IsSuccessStatusCode) { _logger.LogInformation("Done request capture order"); var res = await response.Content.ReadAsStringAsync(); // await _hub.Clients.All.SendAsync("cartcomponent", "From backend server, done with paypal capture payment"); var capturedOrder = QuickType.OrderViewModel.FromJson(res); var order = _mapper.Map <Order>(capturedOrder); await _orderRepo.Add(order); return(new ContentResult { ContentType = "text/html", StatusCode = (int)HttpStatusCode.OK, //window.localStorage.clear(); //Content = "<html><head><script>(function(){window.close()})()</script></head><body></body></html>" Content = $"<html><body><head><script></script></head><div style=\"text-align:center\"><h3>Your payment with Paypal is completed. </h3><a href=\"{_configRoot.BaseAddress}\"><button>Back to Store</button></a><br></body></html>" }); } else { return(new ContentResult { ContentType = "text/html", StatusCode = (int)HttpStatusCode.OK, //Content = "<html><head><script>(function(){window.close()})()</script></head><body></body></html>" Content = response.ToString() }); } }
public async Task HandleAsync(BasketCreatedEvent @event) { _basketAsyncRepository.Add(new Query.ViewModel.Basket { BasketId = @event.BasketId, BuyerId = @event.BuyerId }); await _unitOfWork.SaveChangesAsync(); }
public void AddFoodPerDay(FoodPerDayView foodPerDay) { var foodPerDayEntity = new FoodPerDayEntity() { Day = foodPerDay.Day }; _repoFoodPerDay.Add(foodPerDayEntity); }
public async Task <ActionResult <StudioDto> > PostStudio(StudioDto studioDto) { var studio = _mapper.Map <Studio>(studioDto); studio = await _repository.Add(studio); var result = _mapper.Map <StudioDto>(studio); return(CreatedAtAction("GetStudio", new { id = result.Id }, result)); }
public async Task <ActionResult <RatingDto> > PostRating(RatingDto ratingDto) { var rating = _mapper.Map <Rating>(ratingDto); rating = await _repository.Add(rating); var result = _mapper.Map <RatingDto>(rating); return(CreatedAtAction("GetRating", new { id = result.Id }, result)); }
public async Task <ActionResult <TriviaDto> > PostTrivia(TriviaDto triviaDto) { var trivia = _mapper.Map <Trivia>(triviaDto); trivia = await _repository.Add(trivia); var result = _mapper.Map <TriviaDto>(trivia); return(CreatedAtAction("GetTrivia", new { id = result.Id }, result)); }
public async Task <ActionResult <RentalDto> > PostRental(RentalDto rentalDto) { var rental = _mapper.Map <Rental>(rentalDto); rental = await _repository.Add(rental); var result = _mapper.Map <RentalDto>(rental); return(CreatedAtAction("GetRental", new { id = result.Id }, result)); }
public async Task <ActionResult <MovieDto> > PostMovie(MovieDto movieDto) { var movie = _mapper.Map <Movie>(movieDto); movie = await _repository.Add(movie); var result = _mapper.Map <MovieDto>(movie); return(CreatedAtAction("GetMovie", new { id = result.Id }, result)); }
public void AddFood(FoodView foodView) { var food = new FoodEntity() { //Id = foodView.FoodId, Name = foodView.Name, CaloriesPer100G = foodView.CaloriesPer100G }; _repo.Add(food); }
public async Task <IActionResult> Add(TagViewModel tagViewModel) { if (!ModelState.IsValid) { return(View(tagViewModel)); } var tag = tagViewModel.GetEntity(); await tagRepository.Add(tag); return(RedirectToAction("Index", "Home", new { Area = "Admin" })); }
public IActionResult Post([FromBody] RoleVM model) { if (ModelState.IsValid) { var Output = roleContext.Add(model); if (Output.Result == true) { return(Ok()); } } return(NoContent()); }
public async Task ConfirmAttendace(Attendance attendance, IAsyncRepository <Attendance> attendaceRepository) { var userHadConfirmed = attendaceRepository.GetWhere(exp => exp.EventId == attendance.EventId && exp.UserName == attendance.UserName).Result.Any(); if (userHadConfirmed) { throw new AttendanceExistsException(); } await attendaceRepository.Add(attendance); }
public async Task AddMovieReview(ReviewRequestModel reviewRequest) { if (_currentUserService.UserId != reviewRequest.UserId) { throw new HttpException(HttpStatusCode.Unauthorized, "You are not Authorized to Review"); } var review = new Review { UserId = reviewRequest.UserId, MovieId = reviewRequest.MovieId, ReviewText = reviewRequest.ReviewText, Rating = reviewRequest.Rating, }; await _reviewRepository.Add(review); }
private async void CreateOrder() { try { if (ListOD.Count() > 0) { var newOrder = new OrderHeader(); if (SelectedCus != null) { newOrder.CusID = SelectedCus.CusID; } newOrder.Discount = SelectedDis; if (SelectedLog != null) { newOrder.LogId = SelectedLog.LogID; } newOrder.OrderDate = DateTime.Now; foreach (var i in ListOD) { newOrder.OrderDetails.Add(new OrderDetail() { ProductId = i.ProductID, OrderQty = i.OrderQty, UnitPrice = (decimal)i.UnitPrice, StoreID = i.StoreID }); } var result = await oh_repo.Add(newOrder); MessengerInstance.Send <OrderHeader>(result); } } catch { MessageBox.Show("Có Lỗi"); } }
protected async Task <IActionResult> _AddItem(Model item) { IActionResult result = BadRequest(ResponseDTO.BadRequest()); try { var insertedItem = await _repository.Add(item); result = Ok(ResponseDTO.Ok(insertedItem)); } catch (DbUpdateException ex) { var res = ResponseDTO.BadRequest($"Cannot add new { typeof(Model).Name }."); result = BadRequest(res); _logger.LogError(ex.ToString()); } return(result); }
protected async Task PrepareForInsertOrUpdateAsync <T>( IAsyncRepository <T> repository, IQueryable <T> query, Func <T, IAsyncRepository <T>, IQueryable <T>, CancellationToken, Task <T> > updateConditionExpression, Action <T, T> preUpdateDelegate, T newEntity, CancellationToken cancellationToken) { var foundEntity = await updateConditionExpression(newEntity, repository, query, cancellationToken); if (foundEntity == null) { repository.Add(newEntity); return; } preUpdateDelegate?.Invoke(foundEntity, newEntity); repository.Update(newEntity); }
public async Task AddFavorite(FavoriteRequestModel favoriteRequest) { if (_currentUserService.UserId != favoriteRequest.UserId) { throw new HttpException(HttpStatusCode.Unauthorized, "You are not Authorized to purchase"); } // See if Movie is already Favorite. if (await FavoriteExists(favoriteRequest.UserId, favoriteRequest.MovieId)) { throw new ConflictException("Movie already Favorited"); } var favorite = new Favorite { UserId = favoriteRequest.UserId, MovieId = favoriteRequest.MovieId, }; await _favoriteRepository.Add(favorite); }
public override async Task AddRole(UserRole newRole, int adderRef) { await userRoleRepository.Add(newRole, adderRef); }
public override async Task Add(User newUser, int adderRef) { await repository.Add(newUser, adderRef); }
public async Task Handle(AddAgentCommand request, CancellationToken cancellationToken) => await Agent.Register(Guid.NewGuid(), request.FirstName, request.LastName) .OnSuccess(async agent => await _repository.Add(agent)) .OnSuccess(async agentId => await _unitOfWork.Compleate());
public override async Task Add(Machine MachineInformation, int adderRef) { await repository.Add(MachineInformation, adderRef); }
public override async Task Add(DefinationProcess DefinationProcessInformation, int adderRef) { await repository.Add(DefinationProcessInformation, adderRef); }
public virtual async Task <T> Add(T reg) { return(await _repository.Add(reg)); }
private async void Submit(string obj) { try { var newsup = new Supplier() { Name = Name, Delegate = Delegate, Email = Email, Phone = Phone, }; if (SupImg != null) { newsup.Avatar = SupImg.ConvertToByte(); } if (obj == null) { //Create new sup var objresult = await supplier_repo.Add(newsup); if (objresult != null) { dc = new DialogContent() { Content = "Thêm Thành Công", Tilte = "Thông Báo" }; dialog = new DialogOk() { DataContext = dc }; DialogHost.CloseDialogCommand.Execute(null, null); await DialogHost.Show(dialog, DialogHostId); ListSupplier.Add(objresult); } else { dc = new DialogContent() { Content = "Thêm Thất Bại", Tilte = "Thông Báo" }; dialog = new DialogOk() { DataContext = dc }; DialogHost.CloseDialogCommand.Execute(null, null); await DialogHost.Show(dialog, DialogHostId); } } else { //update sup newsup.SupID = Convert.ToInt32(obj); if (await supplier_repo.Update(newsup)) { dc = new DialogContent() { Content = "Cập Nhật Thành Công", Tilte = "Thông Báo" }; dialog = new DialogOk() { DataContext = dc }; DialogHost.CloseDialogCommand.Execute(null, null); await DialogHost.Show(dialog, DialogHostId); ListSupplier = new ObservableCollection <Supplier>(await supplier_repo.GetAllAsync()); } else { dc = new DialogContent() { Content = "Cập Nhật Thất Bại", Tilte = "Thông Báo" }; dialog = new DialogOk() { DataContext = dc }; DialogHost.CloseDialogCommand.Execute(null, null); await DialogHost.Show(dialog, DialogHostId); } } } catch { dc.Content = "Có Lỗi"; dc.Tilte = "Thông Báo"; dialog = new DialogOk() { DataContext = dc }; DialogHost.CloseDialogCommand.Execute(null, null); await DialogHost.Show(dialog, DialogHostId); } }
public override async Task Add(DomainInformation domainInformation, int adderRef) { await repository.Add(domainInformation, adderRef); }
public override async Task AddRuloProcess(RuloProcess ruloProcess, int adderRef) { await ruloProcessRepository.Add(ruloProcess, adderRef); }