private bool HasProperties(OrderData order, AddOrderModel addOrderModel, int clientId) => order.Name == addOrderModel.Name && order.Surname == addOrderModel.Surname && DateTime.Compare(order.CheckIn, addOrderModel.CheckIn) == 0 && DateTime.Compare(order.CheckOut, addOrderModel.CheckOut) == 0 && order.RoomId == addOrderModel.RoomId && order.ClientId == clientId;
public AddOrderModel Validate(AddOrderModel fltAddOrderModel) { _orderAbstractContext.AddOrderModel = fltAddOrderModel; _orderAbstractContext.DbContext = this.Context; DomesticOrderAbstractValidate orderAmountValidate = new OrderAmountValidate(); //价格验证 DomesticOrderAbstractValidate sameFlightValidate = new SameFlightValidate(); //是否存在相同行程相同乘客的订单 DomesticOrderAbstractValidate czValidate = new CorpCzValidate(); //CZ航司特殊要求验证 DomesticOrderAbstractValidate jdValidate = new CorpJdValidate(); //JD航司特殊要求验证 //DomesticOrderAbstractValidate aduitValidate = new CorpAuditValidate();//差旅订单审核验证 DomesticOrderAbstractValidate corpWhiteListValidate = new CorpWhiteListValidate(_checkPassengerIsInWhiteListBll); //白名单匹配 DomesticOrderAbstractValidate buyRemarkValidate = new B2GBuyRemarkValidate(); //B2G采购备注验证 DomesticOrderAbstractValidate corpOrderValidate = new CorpOrderValidate(); //公司客户订单验证 DomesticOrderAbstractValidate unUsedTicketValidate = new UnUsedTicketValidate(); //是否存在未使用票号 orderAmountValidate.SetNextNode(sameFlightValidate); sameFlightValidate.SetNextNode(czValidate); czValidate.SetNextNode(jdValidate); jdValidate.SetNextNode(corpWhiteListValidate); corpWhiteListValidate.SetNextNode(buyRemarkValidate); buyRemarkValidate.SetNextNode(corpOrderValidate); corpOrderValidate.SetNextNode(unUsedTicketValidate); orderAmountValidate.ActionValidate(_orderAbstractContext); return(fltAddOrderModel); }
public AddOrderModel AddOrder(AddOrderModel addOrderModel) { var orderModel = CreateOrderModel(addOrderModel); orderModelList.Add(orderModel); return(addOrderModel); }
public async Task <ActionResult <int> > AddOrder([FromBody] AddOrderModel value) { return(Ok(await _mediator.Send(new AddOrderRequest() { Model = value }))); }
public async Task Add(AddOrderModel model) { var entity = _mapper.Map <Order>(model); _repository.Add(entity); await _repository.SaveChangesAsync(); }
/// <summary> /// 下配送单接口 /// </summary> /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param> /// <param name="data">请求数据</param> /// <param name="timeOut">代理请求超时时间(毫秒)</param> /// <returns></returns> public static AddOrderJsonResult AddOrder(string accessTokenOrAppId, AddOrderModel data, int timeOut = Config.TIME_OUT) { return(WxOpenApiHandlerWapper.TryCommonApi(accessToken => { var urlFormat = Config.ApiMpHost + "/cgi-bin/express/local/business/order/add?access_token={0}"; return CommonJsonSend.Send <AddOrderJsonResult>(accessToken, urlFormat, data, timeOut: timeOut); }, accessTokenOrAppId)); }
public async Task <IActionResult> Save(AddOrderModel model) { var user = User.Identity.Name; model.UserId = user; await _orderService.Add(model); return(Ok()); }
private void SetupOrderRepositoryAddAsyncMock(AddOrderModel addOrderModel, int clientId) => orderRepositoryMock .Setup(repository => repository.AddAsync(It.Is <OrderData>(order => HasProperties( order, addOrderModel, clientId)))) .ReturnsAsync((OrderData)null);
public static AddOrderModel ToAddModel(this OrderVM orderVM) { var model = new AddOrderModel() { CustomerId = orderVM.CustomerId, OrderItems = orderVM.OrderItems.Select(x => x.ToModel()) }; return(model); }
public static OrderEntity ToEntity(this AddOrderModel model) { var entity = new OrderEntity() { CustomerId = model.CustomerId, OrderDate = DateTime.UtcNow }; return(entity); }
public virtual JsonResult AddOrder(AddOrderModel model, List <HttpPostedFileBase> attachments) { if (!ModelState.IsValid) { return(Json(new ActionResponse <string> { Message = LocalMessage.ValidationFailed })); } var addUser = _userSrv.Insert(model); if (!addUser.IsSuccessful) { return(Json(addUser)); } model.UserId = addUser.Result; var userInRole = new UserInRole { UserId = addUser.Result, RoleId = int.Parse(AppSettings.EndUserRoleId), IsActive = true, ExpireDateSh = PersianDateTime.Now.AddYears(5).ToString(PersianDateTimeFormat.Date) }; if (!_userInRoleBusiness.Value.CheckExist(userInRole)) { _userInRoleBusiness.Value.Insert(userInRole); } model.Status = OrderStatus.WaitForPricing; model.DayToDeliver = byte.Parse(AppSettings.DefaultDayToDeliver); var addOrder = _orderSrv.Add(model); if (!addOrder.IsSuccessful) { return(Json(addUser)); } var addFiles = _attachmentSrv.Insert(addOrder.Result, AttachmentType.OrderFiles, attachments); addOrder.Result.User = new User { FirstName = model.FirstName, LastName = model.LastName, Email = model.Email, MobileNumber = long.Parse(model.MobileNumber) }; return(Json(new { addFiles.IsSuccessful, addFiles.Message, Result = MvcExtention.RenderViewToString(this, MVC.Home.Views.Partials._AfterAdd, addOrder.Result) })); }
public IActionResult Post(AddOrderModel addOrderModel) { if (!addOrderModel.Products.Any()) { return(BadRequest("Product list can not be empty.")); } var totalPriceHelper = new TotalPriceHelper(addOrderModel.Client.Id); var totalPrice = Math.Round(totalPriceHelper.CalculateTotalPrice(addOrderModel.Products), 2); return(Ok(totalPrice)); }
public async Task AddOrderAsyncNullSessionTest() { AddOrderModel addOrderModel = CreateAddOrderModel(Token); SetupSessionRepositoryMock(addOrderModel.Token, null); DefaultResponseModel expected = CreateDeniedDefaultResponseModel(); DefaultResponseModel actual = await orderService.AddAsync(addOrderModel); Assert.AreEqual(expected.IsSuccessful, actual.IsSuccessful); }
private OrderModel CreateOrderModel(AddOrderModel addOrderModel) { var orderModel = new OrderModel { Id = GenerateOrderId(), Client = addOrderModel.Client, Products = addOrderModel.Products, TotalPrice = GetTotalPrice(addOrderModel) }; return(orderModel); }
public IActionResult Post(AddOrderModel addOrderModel) { try { var result = orderRepository.AddOrder(addOrderModel); return(Ok(result)); } catch (Exception ex) { return(BadRequest($"An error occured during adding new product.\n{ex.Message}")); } }
public async Task AddOrderAsyncRoomIsNotAvailableTest() { AddOrderModel addOrderModel = CreateAddOrderModel(Token); SessionData sessionData = CreateSessionData(); SetupSessionRepositoryMock(addOrderModel.Token, sessionData); SetupRoomAvailabilityHandlerMock(addOrderModel, DatesAreValid, RoomIsNotAvailable); DefaultResponseModel expected = CreateDeniedDefaultResponseModel(); DefaultResponseModel actual = await orderService.AddAsync(addOrderModel); Assert.AreEqual(expected.IsSuccessful, actual.IsSuccessful); }
public async Task <bool> AddOrderAsync(AddOrderModel model) { var result = await _orderRep.AddAsync(model.ToEntity()); if (result != null) { foreach (var item in model.OrderItems) { await _orderItemRep.AddAsync(item.ToEntity(result.Id)); } return(true); } return(false); }
public OrderModel AddOrderForClient(AddOrderModel order) { OrderModel addedOrder = new OrderModel() { ID = _ordersList.Max(x => x.ID) + 1, Client = _clientsList.Single(x => x.ID == order.ClientID), PurchasedProductsList = _productsList.Where(x => order.PurchasedProductsIDs.Contains(x.ID)).ToList(), OrderPrice = 0.0m }; CalculateFinalOrderPrice(addedOrder); _ordersList.Add(addedOrder); return(addedOrder); }
public async Task AddOrderAsyncTest() { AddOrderModel addOrderModel = CreateAddOrderModel(); DefaultResponseModel expected = CreateDefaultResponseModel(); SetupOrderServiceAddAsyncMock(addOrderModel, expected); IActionResult actual = await orderApiController.Add(addOrderModel); DefaultResponseModel actualValue = (DefaultResponseModel)(actual as JsonResult).Value; Assert.AreEqual(actualValue.Message, expected.Message); }
public AddOrderResult AddOrder(AddOrderModel model) { var order = _mapper.Map <Order>(model); order.Date = DateTime.Now; order.UserId = _userManager.FindByEmailAsync(User.Identity.Name).Result.Id; order.OrderStatusId = -1; ctx.Orders.Add(order); ctx.SaveChanges(); return(new AddOrderResult() { Successful = true }); }
public ActionResult AddOrder(int supplyId, int authorId = 0) { AddOrderModel model = new AddOrderModel(); model.Authors = providerContext.Authors().Select(c => (AuthorModel)c).ToList(); model.SelectedAuthor = model.Authors.FirstOrDefault().Id; if (authorId > 0) { model.SelectedAuthor = authorId; } model.SupplyId = supplyId; return(View(model)); }
public async Task <BaseResponse <InternalOrder> > AddOrder(AddOrderModel model) { var request = new RestRequest("addOrder", Method.POST); request.AddParameter("auth_id", model.AuthId); request.AddParameter("exch_id", model.ExchId); request.AddParameter("mkt_id", model.MktId); request.AddParameter("order_type_id", model.OrderTypeId); request.AddParameter("price_type_id", model.PriceTypeId); request.AddParameter("limit_price", model.LimitPrice); request.AddParameter("order_quantity", model.OrderQuantity); return(await base.Execute <BaseResponse <InternalOrder> >(request)); }
public void Create(AddOrderModel order) { var user = _context.Users.Single(u => u.Id == order.UserAddedId); var status = (Status)order.Status; Order newOrder = new Order { ClientId = order.ClientId, Status = status, UserAdded = user }; _context.Orders.Add(newOrder); _context.SaveChanges(); }
public IActionResult Update(AddOrderModel model) { var orderToEdit = orderContext.Orders.ToList().Where(x => x.Id == model.OrderId).First(); orderContext.Update(orderToEdit); orderToEdit.ShortDesc = model.ShortDesc; orderToEdit.LongDesc = model.LongDesc; orderToEdit.Price = model.Price; orderToEdit.CategoryId = model.CategoryId; orderContext.SaveChanges(); return(RedirectToAction("Success", "Order")); }
public IActionResult Add(AddOrderModel model) { var orderToAdd = new Order { AccountId = accountContext.findIdByLogin(User.Identity.Name), ShortDesc = model.ShortDesc, LongDesc = model.LongDesc, Price = model.Price, Date = model.Date, CategoryId = model.CategoryId }; orderContext.Add(orderToAdd); orderContext.SaveChanges(); return(RedirectToAction("Success", "Order")); }
public async Task <bool> IsRoomAvailableAsync(AddOrderModel addOrderModel) { DateTime checkIn = addOrderModel.CheckIn; DateTime checkOut = addOrderModel.CheckOut; IReadOnlyCollection <GetOrderModel> orders = await orderRepository.GetAsync(); foreach (var order in orders) { if (IsDatesOverlay(checkIn, checkOut, DateTime.Parse(order.CheckIn), DateTime.Parse(order.CheckOut))) { return(false); } } return(true); }
public string Run() { var client = new HttpClientGateway().Client(); try { client.BaseAddress = _baseAddres; var order = new AddOrderModel() { CustomerName = "Winnie the Pooh", Description = "Pot of Honey", DueDate = DateTime.UtcNow.ToString("o") }; string orderBody; XmlRequestBuilder.TryBuild(order, out orderBody); var requestMessage = CreateRequest("orders", new StringContent(orderBody)); var response = client.SendAsync(requestMessage).Result; response.EnsureSuccessStatusCode(); return(response.Content.ReadAsStringAsync().Result); } catch (AggregateException ae) { foreach (var e in ae.Flatten().InnerExceptions) { Console.Write(e.Message); if (e.InnerException != null) { Console.WriteLine(" : " + e.InnerException); } else { Console.WriteLine(); } } } catch (Exception he) { Console.WriteLine("Exception talking to server: {0}", he); } finally { client.Dispose(); } return(null); }
public ActionResult AddOrder(AddOrderModel model) { if (ModelState.IsValid) { OrderDTO order = new OrderDTO { Book = new BookDTO { Id = model.BookId, Title = model.Title, AuthorId = model.SelectedAuthor }, Author = new AuthorDTO { Id = model.SelectedAuthor }, Cost = model.Cost, Supply = new SupplyDTO { Id = model.SupplyId } }; var result = providerContext.AddOrder(order); if (result.Code == BusinessLayer.OperationStatusEnum.Success) { TempData["OperationStatus"] = true; TempData["OpearionMessage"] = "Книга успешно добавлена"; } else { TempData["OperationStatus"] = false; TempData["OpearionMessage"] = result.Message; } return(RedirectToAction("Index", "ProviderPage")); } model.Authors = providerContext.Authors().Select(c => (AuthorModel)c).ToList(); if (model.SelectedAuthor == 0) { model.SelectedAuthor = model.Authors.FirstOrDefault().Id; } return(View(model)); }
private string PostOrder(HttpClient client) { var order = new AddOrderModel() { CustomerName = "Winnie the Pooh", Description = "Pot of Honey", DueDate = DateTime.UtcNow.ToString("o") }; string orderBody; XmlRequestBuilder.TryBuild(order, out orderBody); var requestMessage = CreateRequest("orders", new StringContent(orderBody)); var response = client.SendAsync(requestMessage).Result; response.EnsureSuccessStatusCode(); return(response.Content.ReadAsStringAsync().Result); }
public async Task AddOrderAsyncValidDataTest() { AddOrderModel addOrderModel = CreateAddOrderModel(Token); SessionData sessionData = CreateSessionData(); UserData userData = CreateUserData(); ClientData clientData = CreateClientData(); SetupSessionRepositoryMock(addOrderModel.Token, sessionData); SetupApplicationUserRepositoryMock(sessionData.UserId, userData); SetupClientRepositoryMock(clientData, userData.Id); SetupOrderRepositoryAddAsyncMock(addOrderModel, clientData.Id); SetupRoomAvailabilityHandlerMock(addOrderModel, DatesAreValid, RoomIsAvailable); DefaultResponseModel expected = CreateSuccessfulDefaultResponseModel(); var actual = await orderService.AddAsync(addOrderModel); Assert.AreEqual(expected.IsSuccessful, actual.IsSuccessful); }