public IActionResult PostOrder(int id, [FromBody] AddOrder addOrder) { var extraItems = addOrder.ExtraItems.Select(e => new ExtraOrderItem(e.Description, e.Price)).ToList(); //para obter o preço do carro, buscar ele no banco var precoCar = _dbContext.Cars.SingleOrDefault(c => c.Id == addOrder.IdCar); // var order = new Order(addOrder.IdCar, addOrder.IdCustomer, precoCar.Price, extraItems); //buscar o cliente para esse pedido // var customer = _dbContext.Customers.SingleOrDefault(c => c.Id == addOrder.IdCustomer); // customer.Purchase(order); _dbContext.Order.Add(order); precoCar.SetAsSold(); _dbContext.SaveChanges(); //persistir a operação //resposta http no swagger return(CreatedAtAction( nameof(GetOrder), new { id = order.IdCustomer, orderid = order.Id }, addOrder )); }
public IHttpActionResult OrderProcess(Order cModel) { try { if (ModelState.IsValid) { using (UnitTestEntities ctx = new UnitTestEntities()) { AddOrder.InsertOrder(cModel); } ObjectFactory.ObjResponse.ResponseMessage = "Save Successfully"; ObjectFactory.ObjResponse.ResponseData = cModel; ObjectFactory.ObjResponse.ResponseStatus = true; return(Ok(ObjectFactory.ObjResponse)); } ObjectFactory.ObjResponse.ResponseMessage = "API Call Fields are required"; ObjectFactory.ObjResponse.ResponseData = ""; ObjectFactory.ObjResponse.ResponseStatus = false; } catch (Exception ex) { ObjectFactory.ObjResponse.ResponseMessage = ex.ToString(); ObjectFactory.ObjResponse.ResponseData = ""; ObjectFactory.ObjResponse.ResponseStatus = false; } return(Ok(ObjectFactory.ObjResponse)); }
public ActionResult Index(Order cModel) { try { if (ModelState.IsValid) { AddOrder.InsertOrder(cModel); string msg = "Record has been saved Successfully!!"; return(RedirectToAction("Index", new { Msg = msg })); } else { //ModelState.AddModelError("", "The Password and Confirm Password do not match."); return(View(cModel)); } } catch (DbEntityValidationException e) { foreach (var eve in e.EntityValidationErrors) { Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State); foreach (var ve in eve.ValidationErrors) { Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage); } } throw; } return(View()); }
public ActionResult Payment(FormCollection fc) { string Name = fc["txtCustumer"]; string Phone = fc["txtPhone"]; string Road = fc["txtRoad"]; int tempCountry = int.Parse(fc["textCountry"]); Country Country = new Services().Country(tempCountry); int tempProvince = int.Parse(fc["textProvince"]); Province Province = new Services().Province(tempProvince); int tempDistrict = int.Parse(fc["textDistrict"]); District District = new Services().District(tempDistrict); int tempWard = int.Parse(fc["textWard"]); Ward Ward = new Services().Ward(tempWard); string[] add = new string[] { Road, Ward.Name, District.Name, Province.Name, Country.CommonName }; var order = new Order(); order.ClientName = Name; order.Address = string.Join(" - ", add); order.PhoneNumber = Phone; order.Hide = false; order.OrderDate = DateTime.Now; decimal totalPrice = 0; var cart = (List <CartItem>)Session[CartSession]; foreach (var i in cart) { totalPrice += (decimal)(i.Quantity * i.Product.ProductPrice); } order.Paid = totalPrice; var id = new AddOrder().Insert(order); var detail = new AddOrderDetail(); try { foreach (var item in cart) { var orderDetail = new OrderDetail(); orderDetail.OrderID = id; orderDetail.ProductID = item.Product.ID; orderDetail.Quantity = item.Quantity; orderDetail.TotalPrice = (decimal)item.Product.ProductPrice; detail.InsertOrderDetail(orderDetail); } } catch (Exception ex) { ex.ToString(); } Session[CartSession] = null; return(Redirect("/thanh-cong")); }
private void BtnAddOrder_Click(object sender, EventArgs e) { AddOrder addOrder = new AddOrder(currentUser, customer); this.Hide(); addOrder.Show(); }
public bool AddOrder(AddOrder addOrder) { var database = _stackExchangeRedisHelper.GetDatabase(); var key = $"ShoppingCartLockAdd_{addOrder.ProductId}"; if (database.LockTake(key, key, TimeSpan.FromSeconds(10))) { var result = true; try { var order = new Order { OrderAmount = addOrder.Amount, ProductId = addOrder.ProductId, UserName = addOrder.UserName }; _shopConext.Orders.Add(order); _shopConext.SaveChanges(); } catch (Exception ex) { result = false; _logger.LogError($"{ex.Message}"); } finally { database.LockRelease(key, key); } return(result); } else { return(false); } }
public ActionResult SingleOrderAdd(AddOrder newentry) { List <Product> prlist = AgroExpressDBAccess.GetAllEnabledProduct(); if (prlist != null) { newentry.productlist = prlist.Select(x => new SelectListItem { Value = x.PKProductId.ToString(), Text = x.ProductName }); } if (ModelState.IsValid) { if (AgroExpressDBAccess.AddSingleOrder(newentry)) { ModelState.Clear(); ViewBag.success = "Order has been placed Successfully"; } else { ViewBag.success = "Sorry, Your order is not placed, Please try again"; } } newentry.OrderPlacingDateTime = newentry.OrderPlacingDateTime; return(View(newentry)); }
public async Task <IActionResult> Post([FromBody] AddOrder command) { var Id = Guid.NewGuid(); await _orderListService.AddOrderAsync(Id, UserId, command.ProductId, command.Amount); return(Created($"/orders/{Id}", null)); }
void prov() { DataTable dt = Connection.getResult(@"Select minAmount from [Product]"); int min = (int)dt.Rows[0][0]; dt = Connection.getResult(@"Select amount from [Product]"); int calc = 0; for (int i = 0; i < dt.Rows.Count; i++) { calc = (int)dt.Rows[i][0]; if (calc <= min) { dt = Connection.getResult(@"Select name from [Product] where amount<=minAmount"); string s = dt.Rows[0][0].ToString(); DialogResult dialog = MessageBox.Show( "На складе осталось минимальное(либо меньше) количество" + " " + s + ". " + "Оформить заказ?", "Уведомление", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (dialog == DialogResult.Yes) { AddOrder order = new AddOrder(); this.Hide(); order.ShowDialog(); this.Show(); } } } }
public ResponseViewModel AddOrder([FromBody] AddOrder data) { foreach (var item2 in data.OrderItem) { if (item2.Qty > 0) { OrderItem orderitem = new OrderItem(); orderitem.OrderID = data.OrderID; orderitem.MenuID = item2.MenuID; orderitem.Qty = item2.Qty; orderitem.Notes = item2.Notes; orderitem.Status = "Order"; orderitem.CreatedBy = "Admin"; orderitem.CreatedDate = DateTime.Now; _context.OrderItem.Add(orderitem); } } if (_context.SaveChanges() > 0) { return(new ResponseViewModel { Status = true }); } else { return(new ResponseViewModel { Status = false }); } }
private void btnAddOrder_Click(object sender, EventArgs e) { AddOrder ordForm = new AddOrder(lbxCustomer.SelectedItem as Customer); DialogResult dr = ordForm.ShowDialog(); lbxCustomerOrdered.Items.Add(ordForm.CurrentOrder); }
public AddOrder GetMenu() { AddOrder AddOrder = new AddOrder(); var category = (from a in _context.Category where a.IsDeleted != true select a).ToList(); List <CategoryViewModel> ListCategoryViewModel = new List <CategoryViewModel>(); foreach (var item in category) { CategoryViewModel CategoryViewModel = new CategoryViewModel(); CategoryViewModel.CategoryID = item.CategoryID; CategoryViewModel.CategoryName = item.CategoryName; var listmenu = (from a in _context.Menu where a.CategoryID == item.CategoryID && a.Status.StatusName == "Ready" && a.IsDeleted != true select new OrderItemViewModel { MenuID = a.MenuID, MenuName = a.MenuName, Price = a.MenuPrice, Content = a.Content, ContentType = a.ContentType }).ToList(); CategoryViewModel.OrderItem = listmenu; ListCategoryViewModel.Add(CategoryViewModel); } AddOrder.Category = ListCategoryViewModel; return(AddOrder); }
FormationOrderAsync(AddOrder order, CancellationToken cancellationToken = default(CancellationToken)) { //todo: rewrite, because there is no time to write as it should try { var apartmentId = Guid.Parse(order.ApartmentId); if (!await IsApartmentFree(order.Dates, apartmentId)) { return((Result <OrderDTO>) Result <OrderDTO> .NotOk <OrderDTO>(null, $"Cannot add order. Dates are not free!")); } ; var apartment = await _db.Apartments.Where(_ => _.Id == apartmentId) .FirstOrDefaultAsync(); OrderDTO dto = new OrderDTO() { TotalCoast = MakeTotalCoast(apartment.Price.Value, order.Dates), Dates = order.Dates }; return((Result <OrderDTO>) Result <OrderDTO> .Ok(dto)); } catch (ArgumentNullException ex) { return((Result <OrderDTO>) Result <OrderDTO> .Fail <OrderDTO>($"Source is null. {ex.Message}")); } }
private void ExecuteChoice(string userChoice) { switch (userChoice) { case "1": DisplayOrder flow1 = _kernel.Get <DisplayOrder>(); //WHAT DOES THIS MEAN IN ENGLISH? flow1.Execute(); break; case "2": AddOrder flow2 = _kernel.Get <AddOrder>(); flow2.Execute(); break; case "3": EditOrder flow3 = _kernel.Get <EditOrder>(); flow3.Execute(); break; case "4": RemoveOrder flow4 = _kernel.Get <RemoveOrder>(); flow4.Execute(); break; case "5": break; default: Console.WriteLine("That was not a valid input."); break; } }
public async Task <IActionResult> AddOrderOk(AddOrder model) { if (!ModelState.IsValid) { return(RedirectToAction("Dashboard", "Admin")); } Order order = new Order(); // check for duplicate and copy info bool hasDublicate = await model.CheckDuplicates(_db, order); if (!hasDublicate) { Event currentEvent = await _db.Events.SingleOrDefaultAsync(x => x.ID == model.EID); currentEvent.Orders.Add(order); _db.Events.Update(currentEvent); // log for admin await _db.Logs.AddAsync(await Log.New("Order", $"New Order: {order.ID}. Reason: {model.Comment} was CREATED", _id, _db)); } else { ViewBag.Message = "This Order already exist."; } return(View(order)); }
private void AddOrder_Click(object sender, RoutedEventArgs e) { Order order = new Order(); Window addOrder = new AddOrder(order); addOrder.ShowDialog(); addOrder.Closed += Addorders_Closed; }
private void metroTile2_Click(object sender, EventArgs e) { this.Hide(); AddOrder addorder = new AddOrder(); addorder.Show(); }
private void butNew_Click(object sender, EventArgs e) { AddOrder order = new AddOrder(); this.Hide(); order.ShowDialog(); update(); this.Show(); }
public async void CreateOrderAsync_Positive_TestAsync() { var options = new DbContextOptionsBuilder <ApartmentContext>() .UseInMemoryDatabase(databaseName: "CreateOrderAsync_PositiveAndNegative_TestAsync") .Options; using (var context = new ApartmentContext(options)) { context.AddRange(_users); await context.SaveChangesAsync(); User userWithApartments = context.Users.AsNoTracking().FirstOrDefault(); foreach (var item in _addresses) { item.CountryId = context.Countries.FirstOrDefault().Id; } for (int i = 0; i < 2; i++) { _apartments[i].OwnerId = userWithApartments.Id; _apartments[i].Address = _addresses[i]; } context.AddRange(_apartments); await context.SaveChangesAsync(); } using (var context = new ApartmentContext(options)) { var service = new OrderUserService(context, _mapper); var user = context.Users.AsNoTracking().FirstOrDefault();; var apartment = context.Apartments.AsNoTracking().FirstOrDefault();; IEnumerable <DateTime> dateTimes = new List <DateTime>() { DateTime.Now.Date }; AddOrder order = new AddOrder() { ApartmentId = apartment.Id.ToString(), Dates = dateTimes }; var resultPositive = await service.CreateOrderAsync(order, user.Id.ToString()); resultPositive.IsSuccess.Should().BeTrue(); resultPositive.Data.Apartment.Title.Should().BeEquivalentTo(apartment.Title); resultPositive.Data.Order.Dates.FirstOrDefault().Should().BeSameDateAs(dateTimes.First()); context.BusyDates.FirstOrDefault().Date.Should().BeSameDateAs(dateTimes.First()); } }
private void AddOrders_OnClick(object sender, RoutedEventArgs e) { _applicationManager.getCustomers(); _applicationManager.getEmployees(); _applicationManager.getProducts(); _applicationManager.GetOrderDetails(); var addOrderForm = new AddOrder(); addOrderForm.Show(); }
private void ClickEndOrder(object sender, RoutedEventArgs e) { AddOrder ad = new AddOrder(); ad.Add(_orderClass, _user.Id_user, paymentSystem()); Singleton s = Singleton.Instance; s.orderList.Remove(_orderClass); _allOrdersWindow.DispayActiveOrders(); this.Close(); }
//poziva pri otvaranju prozora AddBoss pri dodavanju novih boss public AddOrderViewModel(AddOrder addOrderOpen) { order = new vwOrder(); addOrder = addOrderOpen; edit = false; using (Service1Client wcf = new Service1Client()) { EmployeeList = wcf.GetAllEmployee(null).ToList(); AlbumList = wcf.GetAllAlbum(null).ToList(); CustomerList = wcf.GetAllCustomer(null).ToList(); } }
public async Task <IActionResult> AddAsync([FromBody] AddOrder command) { command.CacheId = Guid.NewGuid(); await DispatchAsync(command); var result = new { Id = Cache.Get(command.CacheId) }; return(Json(result)); }
//poziva pri otvaranju prozora AddBoss ali pri editovanju nekog boss public AddOrderViewModel(AddOrder addOrderOpen, vwOrder OrderEdit) { order = OrderEdit; addOrder = addOrderOpen; edit = true; edited = true; using (Service1Client wcf = new Service1Client()) { EmployeeList = wcf.GetAllEmployee(null).ToList(); AlbumList = wcf.GetAllAlbum(null).ToList(); CustomerList = wcf.GetAllCustomer(null).ToList(); } }
private void BtnAction_Click(object sender, RoutedEventArgs e) { Button button = (Button)sender; string orderId = button.Uid; Order order = ToObject <Order>(new OrderService().GetOrderById(orderId)); Window addorders = new AddOrder(order); addorders.Title = "编辑商品"; addorders.Show(); addorders.Closed += Addorders_Closed; }
public void Should_Add_Order() { var netoStore = GetStoreManager(); AddOrder[] addOrder = new AddOrder[] { GetTestAddOrder() }; var result = netoStore.Orders.AddOrder(addOrder); Assert.IsNotNull(result); Assert.AreEqual(Ack.Success, result.Ack); Assert.AreEqual(result.Order.Count, 1); }
public ActionResult SingleOrderAdd() { AddOrder newentry = new AddOrder(); List <Product> prlist = AgroExpressDBAccess.GetAllEnabledProduct(); if (prlist != null) { newentry.productlist = prlist.Select(x => new SelectListItem { Value = x.PKProductId.ToString(), Text = x.ProductName }); } newentry.OrderPlacingDateTime = System.DateTime.Now.Date; return(View(newentry)); }
// GET: Kitchen public ActionResult Index() { List <AddOrder> listdata = new List <AddOrder>(); var order = (from a in db.Order where a.Finish == false && a.IsDeleted == false select a).ToList(); List <Category> OrderCategory = new List <Category>(); foreach (var item in order) { AddOrder data = new AddOrder(); List <OrderItemViewModel> listorderitem = new List <OrderItemViewModel>(); var hasil = from a in db.OrderItem where a.OrderID == item.OrderID && a.Status != "FinishCook" && a.Status != "Cancel" && a.IsDeleted != true && a.Status != "Served" && a.Status != "Paid" select new OrderItemViewModel { OrderItemID = a.OrderItemID, MenuID = a.MenuID, MenuName = a.Menu.MenuName, Qty = a.Qty, Status = a.Status, Notes = a.Notes }; foreach (var item2 in hasil) { listorderitem.Add(item2); } data.OrderID = item.OrderID; data.TypeName = item.Type.TypeName; if (item.Type.TypeName == "Order") { data.TableName = (from a in db.Track where a.OrderID == item.OrderID select a.Table.TableName).FirstOrDefault(); } data.OrderItem = listorderitem; if (data.OrderItem.Count > 0) { listdata.Add(data); } } return(View(listdata)); }
public async Task <IActionResult> AddOrder(int?ID = null) { if (ID == null) { return(RedirectToAction("Dashboard", "Admin")); } AddOrder order = new AddOrder(); // assign event's ID order.EID = (int)ID; // lists for <select> for VType and Ticket type await order.CreateLists(_db); return(View(order)); }
//tmm private void btnTableAddToOrderGrid_Click(object sender, EventArgs e) { try { AddOrder a = new AddOrder(); string selected = cmbTableSizeShow.Text; if (txtTableAddQtty.Text != "" && selected != "") { this.Close(); } else { MessageBox.Show("text is empty or cat is exist"); } } catch { } }
public void TestOrderNumAssignment() { var testOrder = new Order(); testOrder.Name = "Smith"; testOrder.State = "OH"; testOrder.TaxRate = 0.10M; testOrder.ProductType = "Carpet"; testOrder.Area = 5M; testOrder.CostPerSquareFoot = 2M; testOrder.LaborCostPerSquareFoot = 1M; testOrder.MaterialCost = 4M; testOrder.LaborCost = 10M; testOrder.Tax = 10M; testOrder.Total = 10M; AddOrder p = new AddOrder(); var list = p.GetTodaysOrders(); int n = p.GetNextOrderNumber(list); Assert.IsTrue(n == 1); }
/// <summary> /// Method to Place an Order /// </summary> /// <param name="order">order data</param> void IWaiterService.PlaceOrder(AddOrder order) { try { this.waiterBL.PlaceOrder(order); } catch (Exception ex) { ServiceFaultDetails serviceException = new ServiceFaultDetails(); serviceException.ErrorMessage = ex.Message; serviceException.Result = false; throw new FaultException<ServiceFaultDetails>(serviceException); } }
/// <summary> /// Click event to handle Addition of Order /// </summary> /// <param name="sender">sender object</param> /// <param name="e">event data</param> private void BtnAddOrder_Click(object sender, EventArgs e) { try { itemCount = 0; AddOrder order = new AddOrder(); List<FoodItem> lstFoodItem = new List<FoodItem>(); string tableNumber = Convert.ToString(comboBox1.SelectedItem); if (!string.IsNullOrEmpty(tableNumber) && (listView2.Items.Count > 0) ) { order.TableNumber = tableNumber; int i = 0; foreach (ListViewItem lvItem in listView2.Items) { string item = listView2.Items[i].SubItems[0].Text.ToString(); double price = double.Parse(listView2.Items[i].SubItems[1].Text, CultureInfo.InvariantCulture); int quantity = int.Parse(listView2.Items[i].SubItems[2].Text); double subTotal; double.TryParse(listView2.Items[i].SubItems[2].Text, System.Globalization.NumberStyles.Any, CultureInfo.CurrentCulture, out subTotal); lstFoodItem.Add(new FoodItem() { DishName = item, ItemQty = quantity }); i++; } if (lstFoodItem.Count > 0) { order.Items = lstFoodItem; waiterClient.PlaceOrder(order); listView2.Items.Clear(); lblTotal.Text = ""; total = 0; MessageBox.Show("Order Placed Successfully"); } } else { MessageBox.Show("Order list is Empty. Place an Order"); } } catch (FaultException<RestaurantService.Contracts.ServiceFaultDetails> ex) { MessageBox.Show("Error:" + ex.Detail.ErrorMessage); } catch (CommunicationException ex) { MessageBox.Show("Error:" + ex.Message); } catch (NullReferenceException ex) { MessageBox.Show("Error:" + ex.Message); } }
private void AddUserToTask(AddOrder<IUser, int> order) { this.context.AddTaskToUser(order.Model, order.WithIn); }
private void AddTaskRecord(AddOrder<ITaskRecord, int> order) { this.context.AddTaskRecord(order.Model, order.WithIn); }
private void AddTaskComment(AddOrder<ITaskComment, int> order) { this.context.AddTaskComment(order.Model, order.WithIn); }