public ActionResult NewLocation(Models.Location.NewLocation location)
        {
            try
            {
                // if a create another was clicked instead of just submitting the event.
                bool createAnother = false;
                if (Request.Form["createAnother"] != null)
                    createAnother = true;

                var locType = (LocationOwnerType)Enum.Parse(typeof(LocationOwnerType), location.RedirectTo);
                var id = RDN.Library.Classes.Location.LocationFactory.CreateNewLocation(locType, location.LocationName, location.Address1, location.Address2, location.CityRaw, location.Country, location.StateRaw, location.Zip, location.Website, location.OwnerId);

                if (!createAnother)
                {
                    if (locType == LocationOwnerType.calendar)
                        return Redirect(Url.Content("~/calendar/new/" + location.OwnerType + "/" + location.OwnerId.ToString().Replace("-", "") + "/" + id.LocationId.ToString().Replace("-", "")));
                    else if (locType == LocationOwnerType.shop)
                    {
                        var sg = new StoreGateway();
                        var realStore = sg.GetStoreForManager(location.OwnerId);
                        return Redirect(Url.Content("~/store/settings/" + realStore.PrivateManagerId.ToString().Replace("-", "") + "/" + realStore.MerchantId.ToString().Replace("-", "")));
                    }
                }
                else
                {
                    return Redirect(HttpContext.Request.Url.AbsoluteUri + "?u=" + SiteMessagesEnum.sal);
                }
            }
            catch (Exception exception)
            {
                ErrorDatabaseManager.AddException(exception, exception.GetType());
            }
            return View(location);
        }
        public ActionResult StoreHome(Guid? privId, Guid? storeId)
        {
            DisplayStore displayStore = null;
            try
            {
                if (storeId == null)
                {
                    var store = new DisplayStore();
                    //when creating a store, the store is created with the users 
                    //member id or the federation or league id.
                    if (privId == null || privId == new Guid())
                    {
                        privId = RDN.Library.Classes.Account.User.GetMemberId();
                        //check if they already have a store, if they do, we load it.
                        bool hasStore = MemberCache.HasPersonalStoreAlreadyForUser(privId.Value);
                        if (hasStore)
                            return Redirect(Url.Content("~/store/home/" + MemberCache.GetStoreManagerKeysForUrlUser(privId.Value)));
                    }
                    store.InternalReference = privId.Value;
                    NameValueCollection nameValueCollection = HttpUtility.ParseQueryString(Request.Url.Query);
                    string updated = nameValueCollection["u"];

                    if (!String.IsNullOrEmpty(updated) && updated == SiteMessagesEnum.wbc.ToString())
                    {
                        SiteMessage message = new SiteMessage();
                        message.MessageType = SiteMessageType.Error;
                        message.Message = "Wrong Beta Code, Please Try Again.";
                        this.AddMessage(message);
                    }
                    return View(store);
                }
                var sg = new StoreGateway();
                displayStore = sg.GetStoreForManager(storeId, privId, false);
                if (!displayStore.AcceptPaymentsViaStripe && !displayStore.AcceptPaymentsViaPaypal)
                {
                    SiteMessage message = new SiteMessage();
                    message.MessageType = SiteMessageType.Info;
                    message.Message = "Please Setup a Payment Provider in the Store Settings.";
                    this.AddMessage(message);
                }
                else if (!displayStore.IsPublished)
                {
                    SiteMessage message = new SiteMessage();
                    message.MessageType = SiteMessageType.Info;
                    message.Message = "Your Store Is Not Yet Published. Publish the Store in the Settings.";
                    this.AddMessage(message);
                }
            }
            catch (Exception exception)
            {
                ErrorDatabaseManager.AddException(exception, exception.GetType());
            }
            return View(displayStore);
        }
        public ActionResult StoreNewItem(StoreItemDisplayModel storeItem)
        {
            var sg = new StoreGateway();
            try
            {
                StoreItemDisplay display = new StoreItemDisplay();
                display.CanPickUpLocally = storeItem.CanPickUpLocally;
                display.ArticleNumber = storeItem.ArticleNumber;
                display.CanRunOutOfStock = storeItem.CanRunOutOfStock;
                display.Currency = storeItem.Currency;
                display.Description = storeItem.Description;
                display.InternalId = storeItem.InternalId;
                display.Note = storeItem.HtmlNote;
                display.Price = storeItem.Price;
                display.PrivateManagerId = storeItem.PrivateManagerId;
                display.QuantityInStock = storeItem.QuantityInStock;
                display.StoreItemId = storeItem.StoreItemId;
                display.Merchant.Name = storeItem.StoreName;
                display.Weight = storeItem.Weight;
                display.MerchantId = storeItem.MerchantId;
                display.Name = storeItem.Name;
                display.Shipping = storeItem.Shipping;
                display.HasExtraLarge = storeItem.HasExtraLarge;
                display.HasExtraSmall = storeItem.HasExtraSmall;
                display.HasLarge = storeItem.HasLarge;
                display.HasMedium = storeItem.HasMedium;
                display.HasSmall = storeItem.HasSmall;
                display.HasXXLarge = storeItem.HasXXLarge;
                display.ItemTypeEnum = storeItem.ItemTypeEnum;
                display.ItemType = storeItem.ItemType;
                display.ColorTempSelected = storeItem.ColorsSelected;

                display = sg.CreateNewStoreItem(display);
                if (display.StoreItemId > 0)
                    return Redirect(Url.Content("~/store/item/edit/" + display.StoreItemId + "/" + display.PrivateManagerId.ToString().Replace("-", "") + "/" + display.MerchantId.ToString().Replace("-", "")));

            }
            catch (Exception exception)
            {
                ErrorDatabaseManager.AddException(exception, exception.GetType());
            }
            //if the item didn't actually get created.
            var store = sg.GetStoreForManager(storeItem.MerchantId, storeItem.PrivateManagerId, false);
            storeItem.InternalId = store.InternalReference;
            storeItem.MerchantId = store.MerchantId;
            storeItem.PrivateManagerId = store.PrivateManagerId;
            return View(storeItem);
        }
 public ActionResult StoreNewItem(Guid privId, Guid storeId)
 {
     StoreItemDisplayModel storeItem = new StoreItemDisplayModel();
     try
     {
         var sg = new StoreGateway();
         var store = sg.GetStoreForManager(storeId, privId, false);
         storeItem.InternalId = store.InternalReference;
         storeItem.MerchantId = store.MerchantId;
         storeItem.Currency = store.Currency;
         storeItem.PrivateManagerId = store.PrivateManagerId;
         StoreItemTypeEnum[] notInList = { StoreItemTypeEnum.None };
         storeItem.ItemTypeSelectList = StoreItemTypeEnum.Item.ToSelectList(notInList);
         var colors = ColorDisplayFactory.GetColors();
         storeItem.ColorList = new SelectList(colors, "HexColor", "NameOfColor");
     }
     catch (Exception exception)
     {
         ErrorDatabaseManager.AddException(exception, exception.GetType());
     }
     return View(storeItem);
 }
        public ActionResult StoreOrders(Guid privId, Guid storeId)
        {
            DisplayStore displayStore = null;
            try
            {
                NameValueCollection nameValueCollection = HttpUtility.ParseQueryString(Request.Url.Query);
                string updated = nameValueCollection["u"];

                if (!String.IsNullOrEmpty(updated) && updated == SiteMessagesEnum.sced.ToString())
                {
                    SiteMessage message = new SiteMessage();
                    message.MessageType = SiteMessageType.Error;
                    message.Message = "You did not Connect to Stripe. In order to Accept Customer Credit Cards, you should connect to Stripe.";
                    this.AddMessage(message);
                }
                if (!String.IsNullOrEmpty(updated) && updated == SiteMessagesEnum.sca.ToString())
                {
                    SiteMessage message = new SiteMessage();
                    message.MessageType = SiteMessageType.Success;
                    message.Message = "Stripe Connected Successfully.";
                    this.AddMessage(message);
                }

                ViewBag.IsSuccessful = false;
                var sg = new StoreGateway();
                var realStore = sg.GetStoreForManager(storeId, privId, false);

                displayStore = realStore;
            }
            catch (Exception exception)
            {
                ErrorDatabaseManager.AddException(exception, exception.GetType());
            }
            return View(displayStore);

        }