public ActionResult Details(int id) { Domain.Model.Order order = RepoOrd.GetOrderById(id); var viewModel = new OrderViewModel { OrderId = order.Id, SortMethod = "Default", PersonName = order.Username, StoreName = RepoStore.GetStoreById(RepoPers.GetPersonById(order.UserId).StoreId).Name, OrderDate = order.Date, TotalOrderPrice = order.Price, Items = order.Items.Select(y => new ItemViewModel { ItemId = y.Id, ItemName = y.Name, ItemDescription = y.Description, ItemPrice = y.Price, StoreName = RepoStore.GetStoreById(y.StoreId).Name, OrderId = y.OrderId, SellerName = RepoSell.GetSellerById(y.SellerId).Name, TopicName = RepoTopi.GetTopicById(y.TopicId).Topic }).ToList() }; List <string> mySorters = new List <string> { "Default", "Old to New", "New to Old", "Low Price to High Price", "High Price to Low Price" }; ViewData["Sorter"] = new SelectList(mySorters); return(View(viewModel)); }
public ActionResult Finalize() { try { double price = 0; List <Domain.Model.Item> orderItemsList = new List <Domain.Model.Item>(); foreach (var val in MyOrder.itemsInOrder) { orderItemsList.Add(RepoItem.GetItemById(val)); price = price + RepoItem.GetItemById(val).Price; } Domain.Model.Order myNewOrder = new Domain.Model.Order { UserId = RepoPers.GetPeopleByName(MyOrder.Username).First().Id, Date = DateTime.Now, Price = price, Items = orderItemsList }; RepoOrd.AddOrder(myNewOrder); RepoOrd.Save(); MyOrder.Username = ""; MyOrder.itemsInOrder = null; } catch { return(RedirectToAction("Index", "Home")); } return(RedirectToAction("Index", "Home")); }
public static Context.Order UnMapOrder(Domain.Model.Order order) { return(new Context.Order { OrderId = order.Id, OrderDate = order.Date, TotalOrderPrice = order.Price, PersonId = order.UserId, Item = order.Items.Select(UnMapItem).ToList() }); }
public void Save(Domain.Model.Order order, List <Part> partList, string userName) { User user = _userRepo.GetUserByName(userName); order.OrdersUser = user; //TODO: Gör klart if (userName != null && order.Price != 0 && partList.Count > 0) { _orderRepo.SaveOrder(order, partList); } }
public void MappingDetailsByBillet(Domain.Model.Order order, Domain.Model.Billet billet) { this.OrderId = order.Id; this.SubTotal = order.Value; this.TotalMoney = order.Money; this.TotalPoints = order.Point; this.Billet = new Billet() { LinkPayment = billet.PaymentLink }; }
public void SaveOrder(Domain.Model.Order order, List <Part> partList) { order.Sent = false; order.OrdersUser = _context.Users.SingleOrDefault(x => x.Username == order.OrdersUser.Username); _context.Orders.Add(order); foreach (var item in partList) { _context.Parts.Attach(item); } order.Parts = partList; _context.SaveChanges(); }
// GET: Items/Create public IActionResult Delete(int id) { Domain.Model.Order order = RepoOrd.GetOrderById(id); var viewModel = new OrderViewModel { OrderId = order.Id, PersonName = order.Username, StoreName = RepoStore.GetStoreById(RepoPers.GetPersonById(order.UserId).StoreId).Name, OrderDate = order.Date, TotalOrderPrice = order.Price }; return(View(viewModel)); }
public static Domain.Model.Order MapOrderWithDetails(DataAccess.Model.Orders data_orders) { var tempOrder = new Domain.Model.Order(MapCustomer(data_orders.Customer)) { OrderId = data_orders.OrderId, }; foreach (var orderline in data_orders.Orderlines) { var tempProduct = MapProduct(orderline.Product); tempOrder.AllProductsOnOrder.Add(tempProduct); } return(tempOrder); }
public void AddOrder(Domain.Model.Order inputOrder) { if (inputOrder.Id != 0) { _logger.LogWarning($"Order to be added has an ID ({inputOrder.Id}) already: ignoring."); } _logger.LogInformation("Adding order"); Context.Order entity = new Context.Order { PersonId = inputOrder.UserId, OrderDate = inputOrder.Date, TotalOrderPrice = inputOrder.Price, }; entity.OrderId = 0; //_dbContext.Orders.Max(p => p.OrderId)+1; _dbContext.Add(entity); Save(); foreach (var val in inputOrder.Items) { val.OrderId = _dbContext.Orders.Max(p => p.OrderId); Repo.UpdateItem(val); } }
public long Redemption(PagSeguro.Model.Credit credit, Domain.Model.Transaction transaction, Domain.Model.Order order) { PagSeguro.Transaction trans = new PagSeguro.Transaction(); var resultTransaction = new Domain.Model.Transaction(); var orderCreate = this._orderRepository.Create(order); if (orderCreate.Id > 0) { credit.OrderId = orderCreate.Id; if (transaction.Value > 0) { transaction.OrderId = orderCreate.Id; transaction.Description = string.Format(transaction.Description, orderCreate.Id); resultTransaction = this._transactionRepository.CreateTransaction(transaction); //Order Debited this._orderRepository.CreateOrderHistory(new OrderHistory() { OrderId = orderCreate.Id, OrderStatusId = 9 }); } var pagSeguro = trans.CreditCheckout(credit); if (pagSeguro.Success) { Domain.Model.Credit creditCreate = new Model.Credit(); creditCreate.OrderId = orderCreate.Id; creditCreate.Owner = credit.Owner; creditCreate.Brand = credit.Brand; creditCreate.SenderHash = credit.SenderHash; creditCreate.CreditCardToken = credit.CreditCardToken; creditCreate.Session = credit.Session; creditCreate.Parcel = credit.Parcel.Quantity; creditCreate.Value = credit.Parcel.Value; creditCreate.SubTotal = order.Money; creditCreate.Holder = credit.CreditCardHolder.Name; creditCreate.CPF = credit.CreditCardHolder.CPF; creditCreate.DateNasc = credit.CreditCardHolder.BirthDate; creditCreate.Contact = credit.CreditCardHolder.DDD + credit.CreditCardHolder.Phone; creditCreate.Street = credit.BillingAddress.Street; creditCreate.Number = credit.BillingAddress.Number; creditCreate.Complement = credit.BillingAddress.Complement; creditCreate.ZipCode = credit.BillingAddress.ZipCode; creditCreate.District = credit.BillingAddress.District; creditCreate.City = credit.BillingAddress.City; creditCreate.State = credit.BillingAddress.State; creditCreate.FeeAmount = Convert.ToSingle(pagSeguro.FeeAmount); creditCreate.NetAmount = Convert.ToSingle(pagSeguro.NetAmount); creditCreate.Code = pagSeguro.Code; this._orderRepository.CreateCreditByOrderId(creditCreate); int type = Enum.Parse(typeof(Domain.Model.Enum.OrderStatus), pagSeguro.TransactionStatus).GetHashCode(); //Order Debited this._orderRepository.CreateOrderHistory(new OrderHistory() { OrderId = orderCreate.Id, OrderStatusId = type }); this._orderRepository.UpdateOrderDeliveryAddressByCartId(order.CartId, orderCreate.Id); this._cartRepository.UpdateStatusByCartId(order.CartId, 1); } return(orderCreate.Id); } return(0); }
public IHttpActionResult Redemption(Order order) { try { #region Declarations of variables and objects long orderId = 0; string session = null; float total = 0; ClaimsPrincipal principal = Request.GetRequestContext().Principal as ClaimsPrincipal; Participant participant = null; Domain.Model.Cart domainCart = null; var carts = new List <TicketGames.API.Models.Order.Cart>(); Account account = new Account(); var transaction = new Domain.Model.Transaction(); var orderDomain = new Domain.Model.Order(); #endregion long.TryParse(principal.Claims.Where(c => c.Type == "participant_Id").Single().Value, out participantId); if (this.participantId > 0) { #region Get Participant var participantKey = string.Concat("Participant:Id:", this.participantId.ToString(), ":Register"); participant = CacheManager.GetObject <Participant>(participantKey); if (participant == null) { var result = this._participantService.GetParticipant(this.participantId); participant = new Participant(result); } var domainParticipant = participant.MappingDomain(); #endregion #region Get Cart var cartKey = string.Concat("Participant:Id:", this.participantId.ToString(), ":Cart"); domainCart = CacheManager.GetObject <Domain.Model.Cart>(cartKey); if (domainCart == null) { domainCart = this._cartService.Get(this.participantId); } var deliveryAddressResult = this._cartService.Get(this.participantId, domainCart.Id); carts = new TicketGames.API.Models.Order.Cart().CreateCart(domainCart); #endregion #region Get Balance var transactions = this._transactionService.GetTransactions(participantId); if (transactions.Count > 0) { account = new Account().Balances(transactions); } #endregion #region Get Session var key = string.Concat("Participant:Id:", participantId.ToString(), ":Session"); session = CacheManager.GetObject <string>(key); #endregion #region Get Settings var settingsKey = "Settings:Configuration"; List <Domain.Model.Configuration> settings = null; settings = CacheManager.GetObject <List <Domain.Model.Configuration> >(settingsKey); if (settings == null) { settings = this._configurationService.GetSettings(); if (settings != null && settings.Count > 0) { CacheManager.StoreObject(settingsKey, settings, LifetimeProfile.Longest); } } #endregion carts.ForEach(c => total += c.Price * c.Quantity ); orderDomain.ParticipantId = this.participantId; //Status de pedido criado orderDomain.OrderStatusId = 4; orderDomain.OrderHistory.Add(new Domain.Model.OrderHistory() { OrderStatusId = 4 }); orderDomain.Value = total; orderDomain.Money = Convert.ToSingle(total - account.Balance); foreach (var cart in carts) { orderDomain.OrderItems.Add(new Domain.Model.OrderItem() { ProductId = cart.ProductId, RaffleId = cart.RaffleId, Value = cart.Price, Quantity = cart.Quantity }); orderDomain.CartId = cart.CartId; } switch (order.PaymentType) { case PaymentType.Point: { break; } case PaymentType.Billet: { orderDomain.PaymentType = "Billet"; if (account.Balance > 0) { transaction.ParticipantId = this.participantId; transaction.TransactionTypeId = 2; transaction.Description = "Fechamento do pedido {0}"; transaction.Value = account.Balance; orderDomain.Point = account.Balance; orderDomain.PaymentType = "Point + Billet"; } var billet = new Domain.Model.Billet(); billet.Name = participant.Name; billet.CPF = participant.CPF; billet.SenderHash = order.SenderHash; billet.Session = session; billet.Value = orderDomain.Money; var paymentBillet = order.MappingBillet(domainParticipant, deliveryAddressResult, billet); orderId = this._orderService.Redemption(paymentBillet, transaction, orderDomain, settings); break; } case PaymentType.Credit: { orderDomain.PaymentType = "Credit"; if (account.Balance > 0) { transaction.ParticipantId = this.participantId; transaction.TransactionTypeId = 2; transaction.Description = "Fechamento do pedido {0}"; transaction.Value = account.Balance; orderDomain.Point = account.Balance; orderDomain.PaymentType = "Point + Credit"; } var credit = new Domain.Model.Credit(); credit.Owner = order.Card.Owner; credit.SenderHash = order.SenderHash; credit.Brand = order.Card.Brand; credit.CreditCardToken = order.Card.CreditCardToken; credit.Session = session; credit.Parcel = order.Card.Parcel.Quantity; credit.Value = order.Card.Parcel.Value; var paymentCredit = order.MappingCredit(domainParticipant, domainCart, deliveryAddressResult, credit); orderId = this._orderService.Redemption(paymentCredit, transaction, orderDomain); break; } default: break; } if (orderId > 0) { CacheManager.KeyDelete(cartKey); } var pedido = order; } return(Ok(orderId)); } catch (Exception ex) { return(BadRequest(ex.Message)); } }