public ActionResult CreateOrder(SendToShopOrderViewModel sendToShopOrderViewModel)
        {
            if (!this.ValidateWithoutMessaging(sendToShopOrderViewModel))
            {
                return(Content("0"));
            }

            using (var unitOfWork = this.UnitOfWorkFactory.NewUnitOfWork())
            {
                try
                {
                    var sendToShopOrder = Mapper.Map(sendToShopOrderViewModel, new SendToShopOrder());
                    sendToShopOrder.UserId = this.ActiveUser.UserId;
                    this.SendToShopService.PlaceOrder(sendToShopOrder);

                    unitOfWork.Commit();

                    // Notify Shop
                    this.SendToShopService.Notify(sendToShopOrder.SendToShopOrderId);

                    // Update Statuses with Commit
                    sendToShopOrder.SendToShopOrderStatusId = (int)SendToShopOrderStatus.SentToShop;
                    unitOfWork.Commit();

                    return(Content("1"));
                }
                catch (Exception ex)
                {
                    this.LogHandledException(ex);
                    unitOfWork.Rollback();
                    return(this.Content("-1"));                    // General Failure
                }
            }
        }
        public ActionResult Create(int recipeId)
        {
            var partnerId = this.PartnerIdResolver.Resolve();

            if (partnerId == null)
            {
                return(this.Issue404());
            }

            var partner = this.PartnerService.GetPartnerById(partnerId.Value);

            if (partner == null)
            {
                return(this.Issue404());
            }

            var model = new SendToShopOrderViewModel();

            // Make the Data Available
            model.Partner            = partner;
            model.PartnerIngredients = this.PartnerService.GetSendToShopIngredients(partnerId.Value);
            model.PartnerSettings    = this.PartnerService.GetPartnerSendToShopSettings(partnerId.Value);
            model.Recipe             = this.RecipeService.GetRecipeById(recipeId);

            if (model.PartnerIngredients == null || model.PartnerSettings == null || model.Recipe == null)
            {
                return(this.Issue404());
            }

            var orderShell = this.SendToShopService.GetSendToShopOrderShell(this.ActiveUser.UserId, recipeId);

            return(this.View(Mapper.Map(orderShell, model)));
        }
		public ActionResult Create(int recipeId)
		{
			var partnerId = this.PartnerIdResolver.Resolve();

			if (partnerId == null)
			{
				return this.Issue404();
			}

			var partner = this.PartnerService.GetPartnerById(partnerId.Value);

			if (partner == null)
			{
				return this.Issue404();
			}

			var model = new SendToShopOrderViewModel();

			// Make the Data Available
			model.Partner = partner;
			model.PartnerIngredients = this.PartnerService.GetSendToShopIngredients(partnerId.Value);
			model.PartnerSettings = this.PartnerService.GetPartnerSendToShopSettings(partnerId.Value);
			model.Recipe = this.RecipeService.GetRecipeById(recipeId);

			if (model.PartnerIngredients == null || model.PartnerSettings == null || model.Recipe == null)
			{
				return this.Issue404();
			}

			var orderShell = this.SendToShopService.GetSendToShopOrderShell(this.ActiveUser.UserId, recipeId);

			return this.View(Mapper.Map(orderShell, model));
		}
		public ActionResult CreateOrder(SendToShopOrderViewModel sendToShopOrderViewModel)
		{
			if(!this.ValidateWithoutMessaging(sendToShopOrderViewModel))
			{
				return Content("0");
			}

			using(var unitOfWork = this.UnitOfWorkFactory.NewUnitOfWork())
			{
				try
				{
					var sendToShopOrder = Mapper.Map(sendToShopOrderViewModel, new SendToShopOrder());
					sendToShopOrder.UserId = this.ActiveUser.UserId;
					this.SendToShopService.PlaceOrder(sendToShopOrder);

					unitOfWork.Commit();

					// Notify Shop
					this.SendToShopService.Notify(sendToShopOrder.SendToShopOrderId);

					// Update Statuses with Commit
					sendToShopOrder.SendToShopOrderStatusId = (int)SendToShopOrderStatus.SentToShop;
					unitOfWork.Commit();

					return Content("1");
				}
				catch(Exception ex)
				{
					this.LogHandledException(ex);
					unitOfWork.Rollback();
					return this.Content("-1"); // General Failure
				}
			}
		}