public ActionResult Edit([Bind(Include = " DeliveryStatus")] OrderEditViewModel edvm, int id) { var getDeliveryStatusName = (from d in db.OrderDeliveryStatus.Where(d => d.RowID == edvm.DeliveryStatus) select new { d.DeliveryStatus }).FirstOrDefault(); if (getDeliveryStatusName != null) { var getDeliveryStatus = (from d in db.Orders.Where(d => d.OrderID == id) select d).FirstOrDefault(); if (getDeliveryStatus != null) { try { getDeliveryStatus.OrderDeliveryStatus = getDeliveryStatusName.DeliveryStatus; db.SaveChanges(); } catch (Exception ex) { ViewBag.DisplayMessage = "Info"; ModelState.AddModelError("", "Error: " + ex.Message); } } } return(RedirectToAction("Show")); }
public async Task <JsonResult> Edit(OrderEditViewModel request) { var orderManager = new OrderManager(User); var order = await orderManager.GetOrderAsync(request.Id); if (order == null) { return(Json(false, SaleManagentConstants.Errors.OrderNotFound)); } order.GemCategoryId = request.GemCategoryId; order.ProductCategoryId = request.ProductCategoryId; order.ColorFormId = request.ColorFormId; order.Number = request.Number; order.MainStoneSize = request.MainStoneSize; order.Certificate = request.Certificate; order.WordsPrinted = request.WordsPrinted; order.GoldWeightRequirement = request.GoldWeightRequirement; order.SideStoneRequiredment = request.SideStoneRequiredment; order.RadianRequirement = request.RadianRequirement; order.RabbetRequirement = request.RabbetRequirement; order.StoneDescribe = request.StoneDescribe; order.HasOldMaterial = request.HasOldMaterial; order.Remark = request.Remark; order.Updated = DateTime.Now; order.MinChainLength = request.MinChainLength; order.MaxChainLength = request.MaxChainLength; order.HandSize = request.HandSize; order.OrderRushStatus = request.OrderRushStatus; order.IsInsure = request.IsInsure; order.Insurance = request.Insurance; var result = await orderManager.UpdateOrderAsync(order); return(Json(result)); }
// GET: Orders/Edit/5 public async Task <ActionResult> Edit(int id) { //this is the view to 'edit' the cart in order to complete the order. //all we are doing is adding a payment type to the order. var user = await GetCurrentUserAsync(); var viewModel = new OrderEditViewModel(); var order = await _context.Order.FirstOrDefaultAsync(o => o.OrderId == id); var paymentTypes = await _context.PaymentType .Select(pt => new SelectListItem() { Text = pt.Description, Value = pt.PaymentTypeId.ToString() }).ToListAsync(); viewModel.paymentTypes = paymentTypes; viewModel.order = order; if (order.UserId != user.Id) { return(NotFound()); } return(View(viewModel)); }
public ActionResult Create() { var model = new OrderEditViewModel(); ViewBag.Countries = db.Countries.Where(c => c.IsActive).OrderBy(c => c.Name).ToList(); return(View(model)); }
// // GET: /Order/Delete/5 public ActionResult Delete(int id) { Order order = _orderRepository.GetById(id); OrderEditViewModel orderViewModel = Mapper.Map <Order, OrderEditViewModel>(order); return(View(orderViewModel)); }
public OrderEditViewModel Update(OrderEditViewModel OrderEditViewModel) { Order Order = OrderRepo.Update(OrderEditViewModel.ToModel()); unitOfWork.commit(); return(Order.ToEditableViewModel()); }
public ActionResult Details(int Id) { OrderEditViewModel ordervm = new OrderEditViewModel(); Usuario usuario = db.Usuarios.Find(SessionHelper.GetUser()); Order order = db.Orders.Find(Id); ViewBag.Title = "Pedido del Centro " + order.Center.Descripcion; ViewBag.SubTitle = "Estado: " + order.Status.Descripcion; ViewBag.isAdmin = usuario.Rol.IsAdmin; ordervm.Id = order.Id; ordervm.CenterId = order.CenterId; ordervm.OrderProductViewModels = new List <OrderProductViewModel>(); var products = db.Products.Where(x => x.Enable).ToList(); var centerProducts = db.CenterProducts.Where(x => x.CenterId == ordervm.CenterId).ToList(); foreach (var item in products) { OrderProductViewModel orderProduct = new OrderProductViewModel { Product = item.Descripcion, ProductId = item.Id, ProductType = item.SupplieMedical.Descripcion, QuantityDelivered = order.OrderProducts.Where(x => x.ProductId == item.Id).Select(x => x.QuantityDelivered).FirstOrDefault(), Quantity = order.OrderProducts.Where(x => x.ProductId == item.Id).Select(x => x.Quantity).FirstOrDefault(), OutStock = item.OutStock, Stock = centerProducts.Where(x => x.ProductId == item.Id).Select(x => x.Stock).FirstOrDefault() }; ordervm.OrderProductViewModels.Add(orderProduct); } return(View(ordervm)); }
public OrderEditViewModel GetOrder(int id) { OrderEditViewModel ordervm = new OrderEditViewModel(); Order order = db.Orders.Find(id); ordervm.CenterId = order.CenterId; ordervm.Id = order.Id; ViewBag.PasaAEntregado = (order.Status.Id == (int)StatusOrder.Solicitado); ordervm.OrderProductViewModels = new List <OrderProductViewModel>(); ordervm.Center = order.Center.Descripcion; ordervm.Date = order.InitialDate.ToString("dd/MM/yyyy"); ordervm.NroPedido = order.NroPedido.ToString(); var products = db.Products.Where(x => x.Enable).ToList(); var centerProducts = db.CenterProducts.Where(x => x.CenterId == ordervm.CenterId).ToList(); foreach (var item in products) { OrderProductViewModel orderProduct = new OrderProductViewModel { Product = item.Descripcion, ProductId = item.Id, ProductType = item.SupplieMedical.Descripcion, Quantity = order.OrderProducts.Where(x => x.ProductId == item.Id).Select(x => x.Quantity).FirstOrDefault(), QuantityDelivered = order.OrderProducts.Where(x => x.ProductId == item.Id).Select(x => x.QuantityDelivered).FirstOrDefault(), OutStock = item.OutStock, Stock = centerProducts.Where(x => x.ProductId == item.Id).Select(x => x.Stock).FirstOrDefault() }; ordervm.OrderProductViewModels.Add(orderProduct); } return(ordervm); }
public static OrderEditViewModel ToOrderEditViewModel(this Order order) { if (order == null) { return(null); } OrderEditViewModel orderVM = new OrderEditViewModel() { OrderId = order.Id, FirstName = order.FirstName, LastName = order.LastName, Email = order.Email, Address = order.Address, City = order.City, Country = order.Country, Region = order.Region, PostalCode = order.PostalCode, Phone = order.Phone, Fax = order.Fax, DeliveryOptions = order.DeliveryOptions.ToString(), PaymentOptions = order.PaymentOptions.ToString(), Descriptions = order.Descriptions, IsPay = order.PaidOrder }; return(orderVM); }
// GET: Orders/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Order order = db.Orders.Find(id); var customer = db.Customers.Find(order.CustomerId); Address werfadres = new Address(); werfadres.Box = order.customerDeliveryAddress.Box; werfadres.PostalCodeNumber = order.customerDeliveryAddress.PostalCodeNumber; werfadres.StreetName = order.customerDeliveryAddress.StreetName; werfadres.StreetNumber = order.customerDeliveryAddress.StreetNumber; werfadres.Town = order.customerDeliveryAddress.Town; OrderEditViewModel oevm = new OrderEditViewModel(); oevm.order = order; oevm.customer = customer; oevm.address = werfadres; if (order == null) { return(HttpNotFound()); } return(View(oevm)); }
public virtual ActionResult CheckAddress(OrderEditViewModel model) { var serviceFactory = new ServiceFactory(); var addressProviders = AccessManager.Company.AddressProviderInfoList .Where(a => a.Type != (int)AddressProviderType.SelfCorrection) .ToList(); //NOTE: exclude self correction var addressCheckService = serviceFactory.GetAddressCheckServices(LogService, Time, DbFactory, addressProviders); var addressService = new AddressService(addressCheckService, null, null); var validatorService = new OrderValidatorService(LogService, DbFactory, EmailService, Settings, OrderHistoryService, ActionService, PriceService, HtmlScraper, addressService, null, null, Time, AccessManager.Company); var sourceAddress = model.ComposeAddressDto(); AddressDTO correctedAddress = null; var checkResults = validatorService.CheckAddress(CallSource.UI, Db, sourceAddress, null, out correctedAddress); foreach (var checkResult in checkResults) { checkResult.Message = AddressHelper.GeocodeMessageToDisplay(checkResult.Message, true); } var isSuccess = checkResults.Any(r => r.Status < (int)AddressValidationStatus.Invalid && r.Status != (int)AddressValidationStatus.None); AddressViewModel correctedModel = correctedAddress != null ? new AddressViewModel(correctedAddress) : null; var result = new AddressValidationResultViewModel() { IsSuccess = isSuccess, CheckResults = checkResults, CorrectedAddress = correctedModel }; return(new JsonResult { Data = result, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
public ActionResult Edit(OrderEditViewModel model) { if (ModelState.IsValid) { _orderService.Edit(model.Id, model.SupplierId, model.CurrencyId, model.Instructions); return(RedirectToAction("Index")); } return(View(model)); }
// // GET: /Order/Edit/5 public ActionResult Edit(int id) { Order order = _orderRepository.GetById(id); OrderEditViewModel orderViewModel = Mapper.Map <Order, OrderEditViewModel>(order); orderViewModel.ShipTypes = GetAllShipTypes(); return(View(orderViewModel)); }
public async Task <JsonResult> Booking(OrderEditViewModel request, [NamedModelBinder(typeof(CommaSeparatedModelBinder), "attachmentIds")] string[] attachmentIds) { if (!ModelState.IsValid) { return(Json(false, data: ErrorToDictionary())); } var order = Mapper.Map <OrderEditViewModel, Order>(request); var serialNumberManager = new SerialNumberManager(User); var manager = new OrderManager(User); if (string.IsNullOrEmpty(order.Id)) { order.Id = SaleManagentConstants.Misc.OrderPrefix + await serialNumberManager.NextSNAsync(SaleManagentConstants.SerialNames.Order); } else { order.Id = order.Id.Trim(); if (order.Id.Length != 12) { return(Json(false, "订单号格式不正确")); } if (await manager.GetOrderAsync(order.Id) != null) { return(Json(false, "订单号已存在")); } } if (attachmentIds.Any()) { order.Attachments = new List <OrderAttachment>(); attachmentIds.ForEach <string>(a => order.Attachments.Add(new OrderAttachment { FileInfoId = a, OrderId = order.Id, CreatorId = User.Id })); } var result = await manager.CreateOrder(order); if (result.Succeeded) { var operationLogManager = new OrderOperationLogManager(User); await operationLogManager.AddLogAsync(OrderStatus.UnConfirmed, order.Id); return(Json(result.Succeeded, data: new { orderId = order.Id })); } return(Json(result)); }
public ActionResult Edit(OrderEditViewModel order) { if (ModelState.IsValid) { OrderHeader Order = repository.Orders.Where(x => x.Id == order.OrderId).SingleOrDefault(); Order.ModificationDate = DateTime.Now; Order.OrderStatusId = int.Parse(order.OrderStatus); repository.SaveOrder(Order); } return(RedirectToAction("List")); }
public async Task <IActionResult> Edit(OrderEditViewModel model) { if (ModelState.IsValid) { await _orderManager.UpdateOrderStatusByIdAsync(model.Id, (StatusType)model.Status); return(RedirectToAction("List", "Order")); } return(View(model)); }
public ActionResult Edit(OrderEditViewModel viewModel) { if (ModelState.IsValid == false) { return(View(viewModel)); } var dto = Mapper.Map <OrderEditViewModel, OrderDto>(viewModel); this._orderService.EditOrder(dto); return(RedirectToAction("Index")); }
public async Task <IActionResult> Edit(OrderEditViewModel inputModel) { if (!ModelState.IsValid) { return(RedirectToAction("All", "Orders")); } await this.ordersService.EditOrder(inputModel.Id, inputModel.Firstname, inputModel.Lastname, inputModel.Email, inputModel.Price); return(RedirectToAction("All", "Orders")); }
public virtual ActionResult SetIsOversold(int id, bool isOversold) { LogI("SetIsOversold, id=" + id + ", isOversold=" + isOversold); var when = Time.GetAppNowTime(); OrderEditViewModel.SetIsOversold(Db, OrderHistoryService, id, isOversold, when, AccessManager.UserId); return(JsonGet(new { IsOversold = isOversold, IsOversoldUpdateDate = when })); }
public virtual ActionResult OnEditOrder(long id, long?batchId) { LogI("OnEditOrder, Id=" + id); var item = Db.ItemOrderMappings.GetOrderWithItems(WeightService, id, true, true, unmaskReferenceStyles: false); //Show only original orderItems item.BatchId = batchId; var model = new OrderEditViewModel(Db, LogService, item, AccessManager.ShipmentProviderInfoList, AccessManager.IsFulfilment);//{ BatchId = batchId } ViewBag.PartialViewName = "OrderEdit"; return(View("EditEmpty", model)); }
public virtual ActionResult CancelOrder(long id) { LogI("CancelOrder, id=" + id); var userId = AccessManager.UserId; OrderEditViewModel.CancelOrder(Db, LogService, Time, ActionService, OrderHistoryService, id, userId); return(new JsonResult { Data = MessageResult.Success("", id.ToString()), JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
public virtual JsonResult GetListingsToReplace(string styleString, int market, string marketplaceId, long listingId) { var items = OrderEditViewModel.GetListingsToReplace(Db, styleString, market, marketplaceId, listingId); return(Json(new ValueResult <IList <ListingOrderDTO> >(true, "", items), JsonRequestBehavior.AllowGet)); }
public async Task <IActionResult> GetOrderCodes(int id) { OrderEditViewModel vm = new OrderEditViewModel(); vm.cOrders = await _eveDb.cOrders.ToListAsync(); vm.Orders = await _db.Order.Include(x => x.OrderCodes).ToListAsync(); // vm.EveOrderCodes = await getOrderCodesAsync(_eveDb); vm.OrderCodeId = id; vm.SelectedOrderCode = id.ToString(); return(PartialView("Partials/Orders/_PartialSearchForOrderCode", vm)); }
public IActionResult Edit(int id) { Order order = _orderRepository.GetOrder(id); OrderEditViewModel orderEditViewModel = new OrderEditViewModel { Id = order.Id, Name = order.Name, Surname = order.Surname, Table = order.Table, FoodName = order.FoodName }; return(View(orderEditViewModel)); }
public IActionResult ViewDetail(OrderEditViewModel model) { if (ModelState.IsValid) { model.Order.Lines = model.Lines; repository.SaveOrder(model.Order); } else { TempData["error"] = "Some Fields is invalid."; } return(RedirectToAction("Index", new { Id = model.Order.OrderID })); }
public ViewResult Edit(int id) { Order order = _orderRepository.GetOrder(id); OrderEditViewModel orderEditViewModel = new OrderEditViewModel { Id = order.Id, Owner = order.Owner, CupSize = order.CupSize, CupStyle = order.CupStyle, GlitterName = order.GlitterName, Status = order.Status }; return(View(orderEditViewModel)); }
public async Task <IActionResult> Edit(OrderEditViewModel model) { if (ModelState.IsValid) { Order order = _orderRepository.GetOrder(model.Id); order.Owner = model.Owner; order.CupSize = model.CupSize; order.CupStyle = model.CupStyle; order.GlitterName = model.GlitterName; order.Status = model.Status; _orderRepository.Update(order); return(RedirectToAction("index")); } return(View()); }
public IActionResult Edit(OrderEditViewModel model) { if (ModelState.IsValid) { Order order = _orderRepository.GetOrder(model.Id); order.Name = model.Name; order.Surname = model.Surname; order.Table = model.Table; order.FoodName = model.FoodName; _orderRepository.Update(order); return(RedirectToAction("index")); } return(View()); }
public async Task <IActionResult> Edit(int?id) { //If no id is passed in, returns a Not Found page if (id == null) { return(NotFound()); } //Gets the current user ApplicationUser currentUser = await GetCurrentUserAsync(); //Finds the current open order, using the id that was passed in var order = await _context.Order .Include(o => o.PaymentType) .Include(o => o.User) .Include(o => o.OrderProducts) .ThenInclude(op => op.Product) .Where(o => o.UserId == currentUser.Id) .Where(o => o.PaymentTypeId == null) .FirstOrDefaultAsync(m => m.OrderId == id); //If the order doesn't exist, returns a Not Found page if (order == null) { return(NotFound()); } //Creates a ViewModel to hold our order and payment types OrderEditViewModel model = new OrderEditViewModel(); model.Order = order; //fetches all active payment types attributed to the user List <PaymentType> paymentTypes = await _context.PaymentType .Where(pt => pt.UserId == currentUser.Id && pt.Active == true) .ToListAsync(); //If payment types exist, convert them to select list items and add them to the view model if (paymentTypes != null) { model.PaymentTypes = new SelectList(paymentTypes, "PaymentTypeId", "Description", order.PaymentTypeId).ToList(); } //Pulls up our view for this order. If you look at the cshtml for this view, you'll note that, if no payment types were found, the user is given a link to add a new payment type! return(View(model)); }
public virtual ActionResult SetRefundLocked(int id, bool isRefundLocked) { LogI("SetRefundLocked, id=" + id + ", isRefundLocked=" + isRefundLocked); var when = Time.GetAppNowTime(); OrderEditViewModel.SetRefundLocked(Db, OrderHistoryService, id, isRefundLocked, when, AccessManager.UserId); return(new JsonResult { Data = new { IsRefundLocked = isRefundLocked, IsRefundLockedDate = when }, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
public StandardJsonResult CalculateTax(OrderEditViewModel model) { var tax = 0m; var itemDiscount = 0m; if (model.Discount < 0) { itemDiscount = model.Discount / model.Items.Count; } foreach (var item in model.Items) { var taxClassId = productFinder.Find(item.ProductId).TaxClassId; tax += taxService.CalculateTax(model.BillingAddress.CountryCode, model.BillingAddress.RegionId, taxClassId, item.Quantity * (item.ItemPrice + itemDiscount)); } return JsonSuccess(tax); }
public ActionResult Edit(OrderEditViewModel model) { if (!ModelState.IsValid) return JsonValidationError(); var order = orderService.Find(model.Id); Mapper.Map(model.BillingAddress, order.BillingAddress); Mapper.Map(model.ShippingAddress, order.ShippingAddress); order.DateUpdated = DateTime.Now; order.UserComments = model.UserComments; order.Discount = model.Discount; order.ShippingAmount = model.ShippingAmount; order.Subtotal = 0; order.TaxAmount = 0; var itemDiscount = 0m; if (model.Discount < 0) { itemDiscount = model.Discount / model.Items.Count; } foreach (var item in model.Items) { if (item.Id == 0) { var orderItem = new OrderItem { Order = order, ProductId = item.ProductId, ProductSkuId = item.ProductSkuId, Quantity = item.Quantity, Options = item.Options, ItemPrice = item.ItemPrice }; db.OrderItems.Add(orderItem); } else { var orderItem = order.Items.First(i => i.Id == item.Id); Mapper.Map(item, orderItem); } order.Subtotal += item.Quantity * item.ItemPrice; Product product = productFinder.Find(item.ProductId); order.TaxAmount += taxService.CalculateTax(model.BillingAddress.CountryCode, model.BillingAddress.RegionId, product.TaxClassId, (item.ItemPrice + itemDiscount)*item.Quantity); } order.Total = order.Subtotal + order.Discount + order.ShippingAmount; if (!settingService.Get<bool>(SettingField.TaxIncludedInPrices)) order.Total += order.TaxAmount; db.SaveChanges(); return JsonSuccess(new { orderId = order.Id }) .WithSuccess("Order updated successfully".TA()); }
public ActionResult Create() { var model = new OrderEditViewModel(); ViewBag.Countries = db.Countries.Where(c => c.IsActive).OrderBy(c => c.Name).ToList(); return View(model); }
public ActionResult Create(OrderEditViewModel model) { if (!ModelState.IsValid) return JsonValidationError(); var user = customerService.FindAll().FirstOrDefault(u => u.Email == model.UserEmail); if (user == null) { var userModel = new CustomerViewModel { FirstName = model.BillingAddress.FirstName, LastName = model.BillingAddress.LastName, Company = model.BillingAddress.Company, PhoneNumber = model.BillingAddress.Phone, Email = model.UserEmail }; try { user = customerService.AddOrUpdate(userModel); } catch (ArgumentException err) { return JsonError(err.Message); } } // Get addresses var billingAddress = Mapper.Map<Address>(model.BillingAddress); billingAddress.Type = AddressType.Billing; var shippingAddress = Mapper.Map<Address>(model.SameShippingAddress ? model.BillingAddress : model.ShippingAddress); shippingAddress.Type = AddressType.Shipping; var defaultBillingAddress = customerService.GetAddress(user.Id, AddressType.Billing); if (defaultBillingAddress == null || defaultBillingAddress.FirstName == null) { // Add default billing address defaultBillingAddress = Mapper.Map<Address>(model.BillingAddress); defaultBillingAddress.Type = AddressType.Billing; defaultBillingAddress.IsPrimary = true; if (defaultBillingAddress.Id == 0) user.Addresses.Add(defaultBillingAddress); } var defaultShippingAddress = customerService.GetAddress(user.Id, AddressType.Shipping); if (defaultShippingAddress == null || defaultBillingAddress.FirstName == null) { // Add default shipping address defaultShippingAddress = Mapper.Map<Address>(model.SameShippingAddress ? model.BillingAddress : model.ShippingAddress); defaultShippingAddress.Type = AddressType.Shipping; defaultShippingAddress.IsPrimary = true; if (defaultShippingAddress.Id == 0) user.Addresses.Add(defaultShippingAddress); } db.SaveChanges(); // Create order var order = new Order { UserId = user.Id, BillingAddress = billingAddress, ShippingAddress = shippingAddress, DatePlaced = DateTime.Now, DateUpdated = DateTime.Now, IPAddress = Request.UserHostAddress, UserComments = model.UserComments, Status = OrderStatus.AwaitingPayment, Discount = model.Discount, ShippingAmount = model.ShippingAmount, }; db.Orders.Add(order); var itemDiscount = 0m; if (model.Discount < 0) { itemDiscount = model.Discount / model.Items.Count; } foreach (var item in model.Items) { Product product = productFinder.Find(item.ProductId); var orderItem = new OrderItem { Order = order, ProductId = item.ProductId, ProductSkuId = item.ProductSkuId, Quantity = item.Quantity, Options = item.Options, ItemPrice = item.ItemPrice }; db.OrderItems.Add(orderItem); order.Subtotal += orderItem.Quantity * orderItem.ItemPrice; order.TaxAmount += taxService.CalculateTax(billingAddress.CountryCode, billingAddress.RegionId, product.TaxClassId, (orderItem.ItemPrice + itemDiscount) * orderItem.Quantity); } order.Total = order.Subtotal + order.Discount + order.ShippingAmount; if (!settingService.Get<bool>(SettingField.TaxIncludedInPrices)) order.Total += order.TaxAmount; db.SaveChanges(); return JsonSuccess(new { orderId = order.Id }) .WithSuccess("Order created successfully".TA()); }
public StandardJsonResult GetShippingMethods(OrderEditViewModel model) { var result = new List<ShoppingCartShippingMethodsViewModel>(); AddressViewModel address = model.SameShippingAddress ? model.BillingAddress : model.ShippingAddress; // Find zone for country and region (if supplied) ShippingZone zone = shippingService.FindZone(address.CountryCode, address.RegionId); if (zone != null && model.Items.Any()) { List<ShippingMethod> methods = shippingService.FindMethods(zone.Id).ToList(); foreach (ShippingMethod method in methods) { decimal? cost = shippingService.CalculateShipping(method, model.Items.Sum(i => i.Quantity), model.Items.Sum(i => i.Quantity * db.Products.Find(i.ProductId).Weight), model.Items.Sum(i => i.Quantity * i.ItemPrice), Mapper.Map<Address>(address)); if (!cost.HasValue) continue; var methodView = new ShoppingCartShippingMethodsViewModel { Id = method.Id, Name = method.Name, Amount = cost.Value }; result.Add(methodView); } } return JsonSuccess(result.OrderBy(s => s.Amount)); }