Exemplo n.º 1
0
        public static Object SaveInDrafts()
        {
            var    flyer   = WizardFlyer.GetFlyer();
            var    saved   = false;
            String message = null;

            if (flyer != null && flyer.OrderId.HasValue)
            {
                flyer.UpdateMarkup();

                var order = flyer.ToOrder();

                if (String.Compare(order.status, Order.flyerstatus.Incomplete.ToString(), true) != 0)
                {
                    saved   = false;
                    message = String.Format("Save operation is available only for incomplete flyers. This flyer (ID = {0}) status is {1}.", order.order_id.ToString(), order.status.ToUpper());
                }
                else
                {
                    order.Save();
                    saved = true;
                }
            }

            if (!saved)
            {
                message = "Nothing to save.";
            }

            var rootUrl = clsUtility.GetRootHost;
            var result  = new { Result = saved, Message = message, RedirectToUrl = rootUrl + "myflyers.aspx" };

            return(result);
        }
Exemplo n.º 2
0
    private void SetSelectedPricesList()
    {
        if (!String.IsNullOrEmpty(filter.Prices))
        {
            Int32 f;
            selectedPricesList = filter.Prices.Split(',').Select(i =>
            {
                if (Int32.TryParse(i, out f) && f >= 0 && f < pricesListDataSource.Count)
                {
                    return(f);
                }

                return(-1);
            })
                                 .Where(i => i != -1)
                                 .Distinct()
                                 .ToDictionary(i => i, i => pricesListDataSource.Table.Rows[i] as FlyerMeDS.fly_sp_GetListSizeRow);

            if (view.ShouldSaveSelectedPricesIntoFlyer)
            {
                var flyer = WizardFlyer.GetFlyer();

                if (flyer != null)
                {
                    flyer.SelectedPricesList = PricesList.FromPricesList(selectedPricesList);
                }
            }
        }
        else
        {
            selectedPricesList = new Dictionary <Int32, FlyerMeDS.fly_sp_GetListSizeRow>();
        }
    }
Exemplo n.º 3
0
        private void SetResult(Boolean result, String message)
        {
            var isBackgroundCheck = Request.ParseCheckboxValue("backgroundcheck") ?? false;

            if (isBackgroundCheck)
            {
                var checkoutResult = new CheckoutResult
                {
                    Result  = result,
                    Message = message
                };

                Helper.RespondWithJsonObject(checkoutResult, Response);
            }
            else
            {
                if (result)
                {
                    var order = Flyer.ToOrder();

                    order.Save();
                    WizardFlyer.DeleteFlyer();
                    Response.SuppressContent = true;
                    Response.Redirect("~/cart.aspx?orderid=" + order.order_id.ToString());
                }
                else
                {
                    throw new Exception(message);
                }
            }
        }
Exemplo n.º 4
0
        protected void Page_Load(Object sender, EventArgs args)
        {
            RootURL = clsUtility.GetRootHost;
            flyer   = WizardFlyer.GetFlyer();

            SetFlyerType();
            SetItems();
        }
Exemplo n.º 5
0
        private void CreateOrderIfNeeded(WizardFlyer flyer)
        {
            var shouldCreateOrder = Request.IsPost() && (!flyer.OrderId.HasValue);

            if (shouldCreateOrder)
            {
                flyer.ToOrder();
            }
        }
Exemplo n.º 6
0
        protected void Page_Load(Object sender, EventArgs e)
        {
            var layout = Request["l"];

            if (String.IsNullOrEmpty(layout))
            {
                if (!String.IsNullOrEmpty(Request["orderid"]))
                {
                    var order = Helper.GetOrder(Request, Response);

                    Response.Write(order.markup);
                }
                else
                {
                    var flyer = WizardFlyer.GetFlyer();

                    if (flyer == null)
                    {
                        layout = Helper.GetFlyerLayout(null, FlyerTypes.Seller);
                    }
                    else
                    {
                        layout = flyer.Layout != null ? flyer.Layout : Helper.GetFlyerLayout(null, flyer.FlyerType);
                    }
                }
            }

            if (!String.IsNullOrEmpty(layout))
            {
                var innerLayout = layout;

                if (String.Compare(innerLayout, "sampleseller", true) == 0)
                {
                    innerLayout = "ac0_sampleseller";
                }
                else if (String.Compare(innerLayout, "samplebuyer", true) == 0)
                {
                    innerLayout = "ad0_samplebuyer";
                }

                var control = LoadControl(String.Format("~/flyer/markup/{0}.ascx", innerLayout));

                if (MarkupOnly)
                {
                    Controls.Add(control);
                }
                else
                {
                    var previewControl = LoadControl("~/controls/preview.ascx");

                    previewControl.FindControl("body").Controls.Add(control);
                    Controls.Add(previewControl);
                }
            }
        }
Exemplo n.º 7
0
        protected void Page_Load(Object sender, EventArgs e)
        {
            Request.RedirectToHttpIfRequired(Response);

            var shouldRedirect = (Request.UrlReferrer == null || (Request.UrlReferrer.ToString().IndexOf("createflyer.aspx", StringComparison.OrdinalIgnoreCase) >= 0)) && String.IsNullOrEmpty(Request["step"]);

            if (shouldRedirect)
            {
                var url = "~/createflyer/" + PageName + "?step=" + StepTransitions.ElementAt(0).Key;

                WizardFlyer.DeleteFlyer();
                Response.Redirect(url, true);
            }

            InitFields();
            SetWizardStep();
            SetScripts();
            SetSessionData();
            SetControls();
        }
Exemplo n.º 8
0
        private void SetSessionData()
        {
            WizardFlyer flyer = null;
            var         shouldGetFlyerFromOrder = !String.IsNullOrEmpty(Request["orderid"]);

            if (shouldGetFlyerFromOrder)
            {
                var order = Helper.GetOrder(Request, Response, User.Identity.Name);

                if (String.Compare(order.status, Order.flyerstatus.Incomplete.ToString(), true) != 0)
                {
                    Helper.SetErrorResponse(HttpStatusCode.BadRequest, String.Format("Edit operation is available only for incomplete flyers. This flyer (ID = {0}) status is {1}.", order.order_id.ToString(), order.status.ToUpper()));
                }

                flyer = WizardFlyer.FromOrder(order);

                if (order.LastPageNo > 0 && order.LastPageNo < StepTransitions.Count)
                {
                    Response.Redirect(String.Format("{0}createflyer/{1}?step={2}", clsUtility.GetRootHost, PageName, StepTransitions.ElementAt(order.LastPageNo).Key), true);
                }
            }
            else
            {
                flyer = WizardFlyer.GetFlyer();

                if (flyer == null)
                {
                    flyer = WizardFlyer.SetFlyer(FlyerType);
                }

                CreateOrderIfNeeded(flyer);
            }

            currentWizardStep.SetSessionData(Request.IsGet());

            if (renderWizardStep != currentWizardStep)
            {
                renderWizardStep.SetSessionData(true);
            }
        }
Exemplo n.º 9
0
        protected void save_Command(Object sender, CommandEventArgs e)
        {
            var orderId = Request["orderid"];

            if (orderId.HasNoText())
            {
                message.MessageText  = "Provide Order ID to send customer copy.";
                message.MessageClass = MessageClassesEnum.System;
            }
            else
            {
                try
                {
                    var order             = Helper.GetOrder(Request, Response);
                    var flyer             = WizardFlyer.FromOrder(order);
                    var sitePath          = AdminSiteRootUrl;
                    var ordersTable       = new DataTable();
                    var deliveryStartedAt = DateTime.Now.ToString();
                    var emailBody         = String.Empty;
                    var url = "~/flyer/markup/aa_sendtoclients_header.aspx";
                    var nvc = new NameValueCollection();

                    nvc.Add("orderid", flyer.OrderId.ToString());
                    nvc.Add("customername", flyer.Name);
                    nvc.Add("message", Helper.GetUrlEncodedString(textareaNote.Value.Replace("\n", "<br />")));
                    url      += "?" + nvc.NameValueToQueryString();
                    emailBody = Helper.GetPageMarkup(url);

                    emailBody += order.markup;

                    url = "~/flyer/markup/ab_sendtoclients_footer.aspx";
                    nvc = new NameValueCollection();
                    nvc.Add("subscriberid", "client");
                    url       += "?" + nvc.NameValueToQueryString();
                    emailBody += Helper.GetPageMarkup(url);

                    var fromName = flyer.Name + " (" + clsUtility.SiteBrandName + ")";
                    var toEmail  = String.Empty;
                    var toName   = String.Empty;

                    if (inputCopyEmail.Value.Trim().HasNoText())
                    {
                        toEmail = flyer.Email;
                        toName  = flyer.Name;
                    }
                    else
                    {
                        toEmail = inputCopyEmail.Value.Trim();
                        toName  = inputCopyEmail.Value.Trim();
                    }

                    Helper.SendEmail(fromName, toEmail, toName, flyer.EmailSubject, emailBody);
                    message.MessageText  = "Customer Copy has been sent.";
                    message.MessageClass = MessageClassesEnum.Ok;
                }
                catch (Exception ex)
                {
                    message.MessageText  = ex.Message;
                    message.MessageClass = MessageClassesEnum.Error;
                }
            }

            message.RedirectToShowMessage();
        }