Exemplo n.º 1
0
        public ActionResult AcceptOffer(int offerId)
        {
            using (MPContext dbContext = new MPContext())
            {
                var curOffer = dbContext.Offer.Include("Executor").First(offer => offer.Id == offerId);

                OfferTracking newOfferTracking = new OfferTracking();
                newOfferTracking.Offer   = curOffer;
                newOfferTracking.Created = DateTime.Now;
                newOfferTracking.Status  = new OfferStatus("Accepted");
                dbContext.OfferTracking.Add(newOfferTracking);

                dbContext.SaveChanges();
            }

            return(RedirectToAction("ShowMyOrders", "Orders"));
        }
Exemplo n.º 2
0
        public ActionResult TakeOrder(int Id, FormCollection form)
        {
            var curOrderModel = new OrderModel();

            using (MPContext dbContext = new MPContext())
            {
                var currentUserId = User.Identity.GetUserId();

                var curOrder = dbContext.Order.Include("ServiceType").Include("ServiceType.ServiceCathegory").Include("OrderCurrency").First(order => order.Id == Id);

                var curExecutor = dbContext.Executor.FirstOrDefault(ex => ex.UserId == currentUserId);

                var newCreatedStatus = dbContext.OfferStatus.FirstOrDefault(s => s.Title == "Created");

                string descriptionText = form["description"];

                Offer newOffer = new Offer();
                newOffer.Order       = curOrder;
                newOffer.Description = descriptionText;
                newOffer.Executor    = curExecutor;
                dbContext.Offer.Add(newOffer);
                dbContext.SaveChanges();

                OfferTracking newCreatedTracking = new OfferTracking();
                newCreatedTracking.Status  = newCreatedStatus;
                newCreatedTracking.Created = DateTime.Now;
                newCreatedTracking.Offer   = newOffer;
                dbContext.OfferTracking.Add(newCreatedTracking);
                dbContext.SaveChanges();

                //curOrderModel.cathegoryId = curOrder.ServiceType.ServiceCathegory.Id;
                //curOrderModel.cathegoryTitle = curOrder.ServiceType.ServiceCathegory.Title;
                //curOrderModel.orderTitle = curOrder.Title;//curOrderModel.sourceAddress = curOrder.SourceAddress;
                //curOrderModel.destinationAddress = curOrder.DestinationAddress;
                //curOrderModel.orderDueDateTime = curOrder.OrderDueDateTime;
                //curOrderModel.orderCost = curOrder.OrderCost;
                //curOrderModel.orderCurrency = curOrder.OrderCurrency;
            }

            return(View("Order", curOrderModel));
        }