protected override sealed void HandleUnknownAction(string actionName) { if (!User.IsRegistered()) { this.ExecuteBounceToLoginNoAccess("You must log in to view this page", this.TempData); return; } //perform redirect if not authorized for this area UserProfile profile = CurrentUserProfileOrNull; if (profile == null) { this.ExecuteBounceToLoginNoAccess("You must log in with an active account to view this page", this.TempData); return; } StoreFront storeFront = CurrentStoreFrontOrNull; if (storeFront == null) { this.ExecuteBounceToLoginNoAccess("You must log in with an account on an active store front to view this page", this.TempData); return; } //check area permission if (!storeFront.Authorization_IsAuthorized(profile, GStoreAction.Admin_CatalogAdminArea)) { this.ExecuteBounceToLoginNoAccess("You must log in with an account that has permission to view this page", this.TempData); return; } base.HandleUnknownAction(actionName); }
public ActionResult Create(int?clientId, int?storeFrontId) { if (GStoreDb.Clients.IsEmpty()) { AddUserMessage("No Clients in database.", "You must create a Client and Store Front to add a store binding.", UserMessageType.Warning); return(RedirectToAction("Create", "ClientSysAdmin")); } if (GStoreDb.StoreFronts.IsEmpty()) { AddUserMessage("No Store Fronts in database.", "You must create a Store Front to add a store binding.", UserMessageType.Warning); return(RedirectToAction("Create", "StoreFrontSysAdmin")); } StoreBinding model = GStoreDb.StoreBindings.Create(); model.SetDefaultsForNew(Request, clientId, storeFrontId); this.BreadCrumbsFunc = html => this.BindingBreadcrumb(html, model.ClientId, model.StoreFront, model); if (clientId == null || clientId.Value == 0 || clientId.Value == -1) { Client firstClient = GStoreDb.Clients.Where(c => c.StoreFronts.Any()).ApplyDefaultSort().First(); model.Client = firstClient; model.ClientId = firstClient.ClientId; if (storeFrontId == null || storeFrontId.Value == 0) { StoreFront firstStoreFront = firstClient.StoreFronts.AsQueryable().ApplyDefaultSort().First(); model.StoreFront = firstStoreFront; model.StoreFrontId = firstStoreFront.StoreFrontId; } } return(View(model)); }
public void BindData() { try { StoreFront ObjStoreFront = new StoreFront(); DataSet ds = new DataSet(); if (Session["UserType"].ToString() == "4") { ds = ObjStoreFront.GetFleaandTickServices(4); } else { ds = ObjStoreFront.GetFleaandTickServices(Convert.ToInt32(Session["UserType"].ToString())); } if ((ds.Tables[0].Rows.Count > 0) && (ds.Tables[0].Rows[0]["PetType"].ToString() == "1")) { divCatService.Text = ds.Tables[0].Rows[0]["Description"].ToString(); imgCatservice.ImageUrl = Session["HomePath"] + "StoreData/HomeServices/" + ds.Tables[0].Rows[0]["ImageName"].ToString(); imgCatservice.ToolTip = ds.Tables[0].Rows[0]["Description"].ToString(); } if ((ds.Tables[0].Rows.Count > 0) && (ds.Tables[0].Rows[1]["PetType"].ToString() == "2")) { divDogService.Text = ds.Tables[0].Rows[0]["Description"].ToString(); imgDogservice.ImageUrl = Session["HomePath"] + "StoreData/HomeServices/" + ds.Tables[0].Rows[1]["ImageName"].ToString(); imgDogservice.ToolTip = ds.Tables[0].Rows[1]["Description"].ToString(); } } catch (Exception ex) { throw ex; } }
public ActionResult SendTestEmail() { UserProfile profile = CurrentUserProfileOrThrow; if (!profile.AspNetIdentityUser().EmailConfirmed) { AddUserMessage("Test Email not sent", "You must confirm your email address before you can receive email.", UserMessageType.Warning); return(RedirectToAction("Index")); } Client client = CurrentClientOrThrow; StoreFront storeFront = CurrentStoreFrontOrThrow; string subject = "Test Email from " + storeFront.CurrentConfig().Name + " - " + Request.BindingHostName(); string textBody = "Test Email from " + storeFront.CurrentConfig().Name + " - " + Request.BindingHostName(); string htmlBody = "Test Email from " + storeFront.CurrentConfig().Name + " - " + Request.BindingHostName(); bool result = this.SendEmail(profile.Email, profile.FullName, subject, textBody, htmlBody); if (result) { AddUserMessage("Test Email Sent!", "Test Email was sent to '" + profile.Email.ToHtml() + "'.", UserMessageType.Success); GStoreDb.LogUserActionEvent(HttpContext, RouteData, this, UserActionCategoryEnum.Profile, UserActionActionEnum.Profile_SendTestEmail, profile.Email, true, emailAddress: profile.Email); } else { AddUserMessage("Test Email not sent", "Test Email was NOT sent. This store does not have Email send activated.", UserMessageType.Warning); GStoreDb.LogUserActionEvent(HttpContext, RouteData, this, UserActionCategoryEnum.Profile, UserActionActionEnum.Profile_SendTestEmail, "Email Disabled", false, emailAddress: profile.Email); } return(RedirectToAction("Index")); }
public ActionResult Delete(int?id, string Tab, bool returnToFrontEnd = false) { if (!id.HasValue) { return(HttpBadRequest("ProductId = null")); } StoreFront storeFront = CurrentStoreFrontOrThrow; Product product = storeFront.Products.Where(p => p.ProductId == id.Value).SingleOrDefault(); if (product == null) { AddUserMessage("Product not found", "Sorry, the Product you are trying to Delete cannot be found. Product id: [" + id.Value + "] for Store Front '" + storeFront.CurrentConfig().Name.ToHtml() + "' [" + storeFront.StoreFrontId + "]", UserMessageType.Danger); if (returnToFrontEnd) { return(RedirectToAction("Index", "Catalog", new { area = "" })); } if (storeFront.Authorization_IsAuthorized(CurrentUserProfileOrThrow, GStoreAction.Products_Manager)) { return(RedirectToAction("Manager")); } return(RedirectToAction("Index", "CatalogAdmin")); } ProductEditAdminViewModel viewModel = new ProductEditAdminViewModel(product, CurrentUserProfileOrThrow, isDeletePage: true, activeTab: Tab); viewModel.ReturnToFrontEnd = returnToFrontEnd; ViewData.Add("ReturnToFrontEnd", returnToFrontEnd); return(View("Delete", viewModel)); }
protected void LoadValues(StoreFront storeFront, UserProfile userProfile, ValueList valueList) { if (valueList == null) { return; } this.ValueList = valueList; this.Client = valueList.Client; this.ClientId = (valueList.Client == null ? 0 : valueList.ClientId); this.CreateDateTimeUtc = valueList.CreateDateTimeUtc; this.CreatedBy = valueList.CreatedBy; this.CreatedBy_UserProfileId = valueList.CreatedBy_UserProfileId; this.Description = valueList.Description; this.EndDateTimeUtc = valueList.EndDateTimeUtc; this.IsPending = valueList.IsPending; this.Name = valueList.Name; this.Order = valueList.Order; this.StartDateTimeUtc = valueList.StartDateTimeUtc; this.UpdateDateTimeUtc = valueList.UpdateDateTimeUtc; this.UpdatedBy = valueList.UpdatedBy; this.UpdatedBy_UserProfileId = valueList.UpdatedBy_UserProfileId; this.ValueListItems = valueList.ValueListItems; this.ValueListId = valueList.ValueListId; this._valueListItemEditAdminViewModels = null; }
private static bool ProcessWebForm_ToFile(BaseController controller, WebForm webForm, Page page) { if (controller == null) { throw new ArgumentNullException("controller"); } StoreFront storeFront = controller.CurrentStoreFrontOrThrow; if (!controller.ModelState.IsValid) { return(false); } string subject = BuildFormSubject(controller, webForm, page); string bodyText = BuildFormBodyText(controller, webForm, page, false); string virtualDir = storeFront.StoreFrontVirtualDirectoryToMap(controller.Request.ApplicationPath) + "\\Forms\\" + webForm.Name.ToFileName(); string fileDir = controller.Server.MapPath(virtualDir); if (!System.IO.Directory.Exists(fileDir)) { System.IO.Directory.CreateDirectory(fileDir); } string fileName = DateTime.UtcNow.ToFileSafeString() + System.Guid.NewGuid().ToString() + ".txt"; System.IO.File.AppendAllText(fileDir + "\\" + fileName, bodyText); return(true); }
public void FillListsIfEmpty(Client client, StoreFront storeFront) { this.StoreFront = storeFront; this.StoreFrontId = storeFront.StoreFrontId; this.Client = client; this.ClientId = client.ClientId; }
public static bool ActivateStoreFrontOnly(this SystemAdminBaseController controller, int storeFrontId) { StoreFront storeFront = controller.GStoreDb.StoreFronts.FindById(storeFrontId); if (storeFront == null) { controller.AddUserMessage("Activate Store Front Failed!", "Store Front not found by id: " + storeFrontId, AppHtmlHelpers.UserMessageType.Danger); return(false); } if (storeFront.IsActiveDirect()) { controller.AddUserMessage("Store Front is already active.", "Store Front is already active. id: " + storeFrontId, AppHtmlHelpers.UserMessageType.Info); return(false); } storeFront.IsPending = false; storeFront.StartDateTimeUtc = DateTime.UtcNow.AddMinutes(-1); storeFront.EndDateTimeUtc = DateTime.UtcNow.AddYears(100); controller.GStoreDb.StoreFronts.Update(storeFront); controller.GStoreDb.SaveChanges(); controller.AddUserMessage("Activated Store Front", "Activated Store Front '" + (storeFront.CurrentConfig() == null ? "" : storeFront.CurrentConfig().Name.ToHtml()) + "' [" + storeFront.ClientId + "]" + " - Client '" + storeFront.Client.Name.ToHtml() + "' [" + storeFront.Client.ClientId + "]", AppHtmlHelpers.UserMessageType.Info); return(true); }
public void BindData(int ServiceID, int PageID) { StoreFront ObjService = new StoreFront(); DataSet ds = new DataSet(); ds = ObjService.GetServiceDetailFront(ServiceID, PageID); if (ds.Tables[0].Rows.Count > 0) { if (PageID == 1) { ImgService.ImageUrl = Session["HomePath"] + "StoreData/Images/" + ds.Tables[0].Rows[0]["Image"].ToString(); lblTitle.Text = ds.Tables[0].Rows[0]["ServiceTitle"].ToString(); Page.Title = ds.Tables[0].Rows[0]["ServiceTitle"].ToString(); lblServiceDesc.Text = ds.Tables[0].Rows[0]["ServiceDescription"].ToString(); litContent.Text = ContentManager.GetFileContentView(ContentManager.GetPhysicalPath(Session["HomePath"].ToString() + "StoreData/" + ds.Tables[0].Rows[0]["PageName"].ToString())); } if (PageID == 2) { ImgService.ImageUrl = Session["HomePath"] + "StoreData/HomeServices/" + ds.Tables[0].Rows[0]["Image"].ToString(); lblTitle.Text = ds.Tables[0].Rows[0]["ServiceTitle"].ToString(); Page.Title = ds.Tables[0].Rows[0]["ServiceTitle"].ToString(); lblServiceDesc.Text = ds.Tables[0].Rows[0]["ServiceDescription"].ToString(); } if (PageID == 3) { ImgService.ImageUrl = Session["HomePath"] + "StoreData/ServicePageServices/" + ds.Tables[0].Rows[0]["Image"].ToString(); lblTitle.Text = ds.Tables[0].Rows[0]["ServiceTitle"].ToString(); Page.Title = ds.Tables[0].Rows[0]["ServiceTitle"].ToString(); lblServiceDesc.Text = ds.Tables[0].Rows[0]["ServiceDescription"].ToString(); } } else { } }
public WebFormEditAdminViewModel(StoreFront storeFront, UserProfile userProfile, WebForm webForm, string activeTab, bool isStoreAdminEdit = false, bool isReadOnly = false, bool isDeletePage = false, bool isCreatePage = false, string sortBy = "", bool? sortAscending = true) { if (storeFront == null) { throw new ArgumentNullException("storeFront"); } if (userProfile == null) { throw new ArgumentNullException("userProfile"); } if (webForm == null) { throw new ArgumentNullException("webForm", "Web form cannot be null"); } this.IsStoreAdminEdit = isStoreAdminEdit; this.IsActiveDirect = webForm.IsActiveDirect(); this.IsActiveBubble = webForm.IsActiveBubble(); this.IsReadOnly = isReadOnly; this.IsDeletePage = isDeletePage; this.IsCreatePage = isCreatePage; this.ActiveTab = activeTab; this.SortBy = sortBy; this.SortAscending = sortAscending; LoadValues(storeFront, userProfile, webForm); }
public ActionResult DeleteConfirmed(int id) { StoreFront target = GStoreDb.StoreFronts.FindById(id); if (target == null) { //storefront not found, already deleted? overpost? throw new ApplicationException("Error deleting Store Front. Store Front not found. It may have been deleted by another user. StoreFrontId: " + id); } int clientId = target.ClientId; string clientName = target.Client.Name; try { List <StoreFrontConfiguration> configsToDelete = target.StoreFrontConfigurations.ToList(); foreach (var config in configsToDelete) { GStoreDb.StoreFrontConfigurations.Delete(config); } bool deleted = GStoreDb.StoreFronts.Delete(target); GStoreDb.SaveChanges(); if (deleted) { AddUserMessage("Store Front Deleted", "Store Front [" + id + "] for client '" + clientName.ToHtml() + "' [" + clientId + "] was deleted successfully.", UserMessageType.Success); } return(RedirectToAction("Index")); } catch (Exception ex) { AddUserMessage("Store Front Delete Error!", "Error deleting Store Front.\nYou will need to delete with a Seek and Destroy.\nThis Store Front may have child records. Store Front id " + id + "<br/>Exception:" + ex.ToString(), UserMessageType.Danger); return(RedirectToAction("Delete", new { id = id })); } }
public ActionResult SeekAndDestroyConfirmed(int id, bool?deleteEventLogs, bool?deleteFolders) { StoreFront target = GStoreDb.StoreFronts.FindById(id); if (target == null) { //client not found, already deleted? overpost? AddUserMessage("Store Front Delete Error!", "Store Front not found Store Front Id: " + id + "<br/>Store Front may have been deleted by another user.", UserMessageType.Danger); return(RedirectToAction("Index")); } StoreFrontConfiguration config = target.CurrentConfigOrAny(); string name = config == null ? "id [" + target.StoreFrontId + "]" : config.Name; string folder = config == null ? null : config.Folder; string folderToMap = config == null ? null : config.StoreFrontVirtualDirectoryToMap(Request.ApplicationPath); try { string report = SeekAndDestroyChildRecordsNoSave(target, deleteEventLogs ?? true, deleteFolders ?? true); AddUserMessage("Seek and Destroy report.", report.ToHtmlLines(), UserMessageType.Info); bool deleted = GStoreDb.StoreFronts.DeleteById(id); GStoreDb.SaveChangesEx(false, false, false, false); if (deleted) { AddUserMessage("Store Front Deleted", "Store Front '" + name.ToHtml() + "' [" + id + "] was deleted successfully.", UserMessageType.Success); } } catch (Exception ex) { AddUserMessage("Store Front Seek and Destroy Error!", "Error with Seek and Destroy for Store Front '" + name.ToHtml() + "' [" + id + "].<br/>This Store Front may have child records.<br/>Exception:" + ex.ToString(), UserMessageType.Danger); } return(RedirectToAction("Index")); }
public List<SelectListItem> StoreFrontConfigList(StoreFront storeFront) { if (storeFront == null) { throw new ArgumentNullException ("storeFront"); } StoreFrontConfiguration currentConfig = storeFront.CurrentConfig(); int currentconfigId = 0; if (currentConfig != null) { currentconfigId = currentConfig.StoreFrontConfigurationId; } List<SelectListItem> list = new List<SelectListItem>(); List<StoreFrontConfiguration> orderedConfigs = storeFront.StoreFrontConfigurations.AsQueryable().ApplyDefaultSort().ToList(); List<SelectListItem> listItemQuery = orderedConfigs.Select(c => new SelectListItem() { Value = c.StoreFrontConfigurationId.ToString(), Text = (c.StoreFrontConfigurationId == currentconfigId ? " [Current Active] " : "") + c.ConfigurationName + " [" + c.StoreFrontConfigurationId + "]" + (c.IsPending ? " [INACTIVE]" : " [" + c.StartDateTimeUtc.ToLocalTime().ToShortDateString() + " to " + c.EndDateTimeUtc.ToLocalTime().ToShortDateString() + "]"), Selected = (c.StoreFrontConfigurationId == currentconfigId) }).ToList(); list.AddRange(listItemQuery.ToList()); return list; }
/// <summary> /// Checks if a file exists in storefront folder, then client folder, then server folder, otherwise returns 404 /// </summary> /// <param name="path"></param> /// <returns></returns> protected ActionResult StoreFile(string path, bool isImage = false) { if (string.IsNullOrWhiteSpace(path)) { return(HttpForbidden("Directory Listing Denied: /")); } StoreFront storeFront = null; try { storeFront = base.CurrentStoreFrontOrThrow; } catch (Exception ex) { if (ex is GStoreData.Exceptions.StoreFrontInactiveException || ex.GetBaseException() is GStoreData.Exceptions.StoreFrontInactiveException) { //storefront is inactive, just show server file System.Diagnostics.Debug.Print("--StoreFile - StoreFront is inactive for file: " + path); } else if (ex is GStoreData.Exceptions.NoMatchingBindingException || ex.GetBaseException() is GStoreData.Exceptions.NoMatchingBindingException) { //no matching binding, just show server file System.Diagnostics.Debug.Print("--StoreFile - No matching binding found; for file: " + path); } else if (ex is GStoreData.Exceptions.DatabaseErrorException || ex.GetBaseException() is GStoreData.Exceptions.DatabaseErrorException) { //databse error. just show server file System.Diagnostics.Debug.Print("--StoreFile - Database Error: " + ex.Message + " - for file: " + path); } else { throw new ApplicationException("Error getting CurrentStoreFront for StoreFile controller.", ex); } } Client client = null; if (storeFront != null) { client = storeFront.Client; } string fullPath = storeFront.ChooseFilePath(client, path, Request.ApplicationPath, Server); if (string.IsNullOrEmpty(fullPath) && isImage) { path = "Images/NotFound.png"; fullPath = storeFront.ChooseFilePath(client, path, Request.ApplicationPath, Server); } if (string.IsNullOrEmpty(fullPath)) { return(HttpNotFound((isImage ? "Image" : "Store File") + " not found: " + path)); } string mimeType = MimeMapping.GetMimeMapping(fullPath); return(new FilePathResult(fullPath, mimeType)); }
public List <SelectListItem> StoreFrontConfigList(StoreFront storeFront) { if (storeFront == null) { throw new ArgumentNullException("storeFront"); } StoreFrontConfiguration currentConfig = storeFront.CurrentConfig(); int currentconfigId = 0; if (currentConfig != null) { currentconfigId = currentConfig.StoreFrontConfigurationId; } List <SelectListItem> list = new List <SelectListItem>(); List <StoreFrontConfiguration> orderedConfigs = storeFront.StoreFrontConfigurations.AsQueryable().ApplyDefaultSort().ToList(); List <SelectListItem> listItemQuery = orderedConfigs.Select(c => new SelectListItem() { Value = c.StoreFrontConfigurationId.ToString(), Text = (c.StoreFrontConfigurationId == currentconfigId ? " [Current Active] " : "") + c.ConfigurationName + " [" + c.StoreFrontConfigurationId + "]" + (c.IsPending ? " [INACTIVE]" : " [" + c.StartDateTimeUtc.ToLocalTime().ToShortDateString() + " to " + c.EndDateTimeUtc.ToLocalTime().ToShortDateString() + "]"), Selected = (c.StoreFrontConfigurationId == currentconfigId) }).ToList(); list.AddRange(listItemQuery.ToList()); return(list); }
public ActionResult Delete(int?id, string Tab, bool returnToFrontEnd = false) { if (!id.HasValue) { return(HttpBadRequest("ProductCategoryId = null")); } StoreFront storeFront = CurrentStoreFrontOrThrow; ProductCategory productCategory = storeFront.ProductCategories.Where(pc => pc.ProductCategoryId == id.Value).SingleOrDefault(); if (productCategory == null) { AddUserMessage("Category not found", "Sorry, the Category you are trying to Delete cannot be found. Category id: [" + id.Value + "] for Store Front '" + storeFront.CurrentConfig().Name.ToHtml() + "' [" + storeFront.StoreFrontId + "]", UserMessageType.Danger); if (returnToFrontEnd) { return(RedirectToAction("ViewCategoryByName", "Catalog", new { area = "", urlName = productCategory.UrlName })); } return(RedirectToAction("Manager")); } CategoryEditAdminViewModel viewModel = new CategoryEditAdminViewModel(productCategory, CurrentUserProfileOrThrow, isDeletePage: true, activeTab: Tab); viewModel.ReturnToFrontEnd = returnToFrontEnd; return(View("Delete", viewModel)); }
public IActionResult Index() { int index = Convert.ToInt32(RouteData.Values["id"]); int nextIndex = index + 1; if (nextIndex >= Movies.Count) { nextIndex = 0; } int prevIndex = index - 1; if (prevIndex < 0) { prevIndex = Movies.Count - 1; } StoreFront storeFront = new StoreFront(); storeFront.Index = index; storeFront.NextIndex = nextIndex; storeFront.PrevIndex = prevIndex; storeFront.Movie = Movies[index]; return(View(storeFront)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,StoreFrontName,StoreFrontUrl")] StoreFront storeFront) { if (id != storeFront.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(storeFront); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!StoreFrontExists(storeFront.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(storeFront)); }
// // GET: /Store/ public ActionResult Index() { var data = new StoreFront(); using (var db = new StoreRepository()) { data.Categories = db.GetCategories(1); var prodgroup = new ProductsGroup(); prodgroup.Displayname = "Display ID One"; prodgroup.Products = db.GetProductsByInterest(1); data.ProductsByInterestsList.Add(prodgroup); prodgroup = new ProductsGroup(); prodgroup.Displayname = "Display ID Two"; prodgroup.Products = db.GetProductsByInterest(2); data.ProductsByInterestsList.Add(prodgroup); prodgroup = new ProductsGroup(); prodgroup.Displayname = "Display ID Three"; prodgroup.Products = db.GetProductsByInterest(3); data.ProductsByInterestsList.Add(prodgroup); } return View(data); }
protected void ProcessFileUploads(ProductBundleEditAdminViewModel viewModel, StoreFront storeFront) { string virtualFolder = storeFront.CatalogProductBundleContentVirtualDirectoryToMap(Request.ApplicationPath); string fileFolder = Server.MapPath(virtualFolder); if (!System.IO.Directory.Exists(fileFolder)) { System.IO.Directory.CreateDirectory(fileFolder); } HttpPostedFileBase imageFile = Request.Files["ImageName_File"]; if (imageFile != null && imageFile.ContentLength != 0) { string newFileName = imageFile.FileNameNoPath(); if (!string.IsNullOrEmpty(Request.Form["ImageName_ChangeFileName"])) { newFileName = viewModel.UrlName + "_Image." + imageFile.FileName.FileExtension(); } try { imageFile.SaveAs(fileFolder + "\\" + newFileName); } catch (Exception ex) { throw new ApplicationException("Error saving bundle image file '" + imageFile.FileName + "' as '" + newFileName + "'", ex); } viewModel.ImageName = newFileName; AddUserMessage("Image Uploaded!", "Bundle Image '" + imageFile.FileName.ToHtml() + "' " + imageFile.ContentLength.ToByteString() + " was saved as '" + newFileName + "'", UserMessageType.Success); } }
public static void SetDefaultsForNew(this ProductBundle productBundle, StoreFront storeFront) { if (storeFront == null) { throw new ArgumentNullException("storeFront"); } productBundle.ClientId = storeFront.ClientId; productBundle.Client = storeFront.Client; productBundle.StoreFrontId = storeFront.StoreFrontId; productBundle.StoreFront = storeFront; if (storeFront.ProductBundles == null || storeFront.ProductBundles.Count == 0) { productBundle.Name = "New Product Bundle"; productBundle.Order = 100; } else { productBundle.Order = (storeFront.ProductBundles.Max(nb => nb.Order) + 10); productBundle.Name = "New Product Bundle " + productBundle.Order; } productBundle.UrlName = productBundle.Name.Replace(' ', '_'); productBundle.ImageName = null; productBundle.MaxQuantityPerOrder = 0; productBundle.AvailableForPurchase = true; productBundle.MetaDescription = productBundle.Name; productBundle.MetaKeywords = productBundle.Name; productBundle.IsPending = false; productBundle.EndDateTimeUtc = DateTime.UtcNow.AddYears(100); productBundle.StartDateTimeUtc = DateTime.UtcNow.AddMinutes(-1); }
public ValueListEditAdminViewModel(StoreFront storeFront, UserProfile userProfile, ValueList valueList, string activeTab, bool isStoreAdminEdit = false, bool isReadOnly = false, bool isDeletePage = false, bool isCreatePage = false, string sortBy = "", bool?sortAscending = true) { if (storeFront == null) { throw new ArgumentNullException("storeFront"); } if (userProfile == null) { throw new ArgumentNullException("userProfile"); } if (valueList == null) { throw new ArgumentNullException("valueList", "valueList cannot be null"); } this.IsStoreAdminEdit = isStoreAdminEdit; this.IsActiveDirect = valueList.IsActiveDirect(); this.IsActiveBubble = valueList.IsActiveBubble(); this.IsReadOnly = isReadOnly; this.IsDeletePage = isDeletePage; this.IsCreatePage = isCreatePage; this.ActiveTab = activeTab; this.SortBy = sortBy; this.SortAscending = sortAscending; LoadValues(storeFront, userProfile, valueList); }
public static void SetDefaultsForNew(this NavBarItem navBarItem, StoreFront storeFront) { if (storeFront == null) { throw new ArgumentNullException("storeFront"); } navBarItem.ClientId = storeFront.ClientId; navBarItem.Client = storeFront.Client; navBarItem.StoreFrontId = storeFront.StoreFrontId; navBarItem.StoreFront = storeFront; if (storeFront.NavBarItems == null || storeFront.NavBarItems.Count == 0) { navBarItem.Name = "New Menu Item"; navBarItem.Order = 100; } else { navBarItem.Order = (storeFront.NavBarItems.Max(nb => nb.Order) + 10); navBarItem.Name = "New Menu Item " + navBarItem.Order; } navBarItem.ForRegisteredOnly = false; navBarItem.ForAnonymousOnly = false; navBarItem.IsPage = true; navBarItem.OpenInNewWindow = false; navBarItem.UseDividerBeforeOnMenu = true; navBarItem.UseDividerAfterOnMenu = false; navBarItem.IsPending = false; navBarItem.EndDateTimeUtc = DateTime.UtcNow.AddYears(100); navBarItem.StartDateTimeUtc = DateTime.UtcNow.AddMinutes(-1); }
/* This event is use to update the row containt after checking the duplicate entry*/ protected void gdvStyle_RowUpdating(object sender, GridViewUpdateEventArgs e) { GridViewRow row = gdvStyle.Rows[e.RowIndex]; if (row != null) { StyleID = Convert.ToInt32(gdvStyle.DataKeys[e.RowIndex].Value); Label lblStyleName = (Label)gdvStyle.Rows[e.RowIndex].FindControl("lblStyleName"); TextBox txtStyleName = (TextBox)gdvStyle.Rows[e.RowIndex].FindControl("txtStyleName"); if (txtStyleName.Text == "") { MessageBox("Please enter Style Name."); } else { StoreFront ObjStoreFront = new StoreFront(); int Count = ObjStoreFront.UpdateStyle(StyleID, txtStyleName.Text.Trim()); if (Count == 1) { SuccesfullMessage("Style updated successfully."); gdvStyle.EditIndex = -1; BindGrid(); } else { ErrMessage("Duplicate Style name."); gdvStyle.EditIndex = -1; BindGrid(); } } } }
public ValueListEditAdminViewModel(StoreFront storeFront, UserProfile userProfile, ValueList valueList, string activeTab, bool isStoreAdminEdit = false, bool isReadOnly = false, bool isDeletePage = false, bool isCreatePage = false, string sortBy = "", bool? sortAscending = true) { if (storeFront == null) { throw new ArgumentNullException("storeFront"); } if (userProfile == null) { throw new ArgumentNullException("userProfile"); } if (valueList == null) { throw new ArgumentNullException("valueList", "valueList cannot be null"); } this.IsStoreAdminEdit = isStoreAdminEdit; this.IsActiveDirect = valueList.IsActiveDirect(); this.IsActiveBubble = valueList.IsActiveBubble(); this.IsReadOnly = isReadOnly; this.IsDeletePage = isDeletePage; this.IsCreatePage = isCreatePage; this.ActiveTab = activeTab; this.SortBy = sortBy; this.SortAscending = sortAscending; LoadValues(storeFront, userProfile, valueList); }
public WebFormEditAdminViewModel(StoreFront storeFront, UserProfile userProfile, WebForm webForm, string activeTab, bool isStoreAdminEdit = false, bool isReadOnly = false, bool isDeletePage = false, bool isCreatePage = false, string sortBy = "", bool?sortAscending = true) { if (storeFront == null) { throw new ArgumentNullException("storeFront"); } if (userProfile == null) { throw new ArgumentNullException("userProfile"); } if (webForm == null) { throw new ArgumentNullException("webForm", "Web form cannot be null"); } this.IsStoreAdminEdit = isStoreAdminEdit; this.IsActiveDirect = webForm.IsActiveDirect(); this.IsActiveBubble = webForm.IsActiveBubble(); this.IsReadOnly = isReadOnly; this.IsDeletePage = isDeletePage; this.IsCreatePage = isCreatePage; this.ActiveTab = activeTab; this.SortBy = sortBy; this.SortAscending = sortAscending; LoadValues(storeFront, userProfile, webForm); }
// Start is called every time the script is enabled and before the first frame update void Start() { // Initialize outside list ListOfCustomersOutside = new List <NewCustomer>(); // 1. Create x (14 in my case) Customers // (Can change ammount in Unity inspector since this is a MonoBehaviour script and the GameObject is public) for (int i = 0; i < numberOfCustomers; i++) { var newCustomer = Instantiate(customerPrefab); var customerScript = newCustomer.GetComponent <NewCustomer>(); ListOfCustomersOutside.Add(customerScript); for (int n = 0; n < ListOfCustomersOutside.Count; n++) { ListOfCustomersOutside[n].name = "Customer #" + n.ToString(); } if (OnCustomerSpawnedListeners != null) { OnCustomerSpawnedListeners(newCustomer.GetComponent <NewCustomer>()); } newCustomer.SetActive(false); } // 2. Every x (3 seconds in my case) seconds 1 customer enters the store, moves to a pre defined free random point and stops // (Can change ammount in Unity inspector since this is a MonoBehaviour script and the GameObject is public) // Need a reference to the storefront. storeFront = storeGameObject.GetComponentInChildren <StoreFront>(); InvokeRepeating("SendCustomerToStoreFront", intervalBetweenCustomerEnteringShop, intervalBetweenCustomerEnteringShop); }
protected void btnLogin_Click(object sender, EventArgs e) { try { StoreFront objStoreFront = new StoreFront(); DataSet ds = new DataSet(); ds = objStoreFront.GetLoginUser(txtUserName.Text.Trim(), txtpassword.Text.Trim()); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["IsActive"].ToString().ToLower() == "false") { Session["UserName"] = ds.Tables[0].Rows[0]["UserName"].ToString(); Session["MemberName"] = ds.Tables[0].Rows[0]["FullName"].ToString(); Session["UserID"] = ds.Tables[0].Rows[0]["UserID"].ToString(); Session["IsLogin"] = "******"; Session["UserType"] = ds.Tables[0].Rows[0]["UserType"].ToString(); lblLoginerror.Visible = false; Response.Redirect("~/mobileweb/MB_index.aspx"); } else { lblLoginerror.Visible = true; lblLoginerror.Text = "Your Account Is Disabled By Administrator of This Site. Please Contact Administrator."; } } else { lblLoginerror.Visible = true; } } catch (Exception ex) { throw ex; } }
protected void btnUpdate_Click(object sender, EventArgs e) { StoreFront ObjStoreFront = new StoreFront(); ObjStoreFront.UpdateBanerImage(Convert.ToInt32(Request.QueryString["BanerID"].ToString()), ViewState["ImageName"].ToString()); SuccesfullMessage("Banner uploaded successfully"); }
public void BindData() { if (Request.Cookies["IsLogin"] == null) { HttpCookie c = new HttpCookie("IsLogin", "0"); c.Expires = DateTime.Now.AddDays(Convert.ToDouble(ConfigurationManager.AppSettings["addCookieForDay"])); Response.Cookies.Add(c); } StoreFront ObjStoreFront = new StoreFront(); DataSet ds = new DataSet(); if (Session["UserType"].ToString() == "4") { ds = ObjStoreFront.GetHomePageServices(4); } else { ds = ObjStoreFront.GetHomePageServices(Convert.ToInt32(Session["UserType"].ToString())); } if ((ds.Tables[0].Rows.Count > 0) && (ds.Tables[0].Rows[0]["PetType"].ToString() == "1")) { divCatService.InnerHtml = ds.Tables[0].Rows[0]["Description"].ToString(); imgCatservice.ImageUrl = Session["HomePath"] + "StoreData/HomeServices/" + ds.Tables[0].Rows[0]["ImageName"].ToString(); imgCatservice.ToolTip = ds.Tables[0].Rows[0]["Description"].ToString(); } if ((ds.Tables[0].Rows.Count > 0) && (ds.Tables[0].Rows[1]["PetType"].ToString() == "2")) { divDogService.InnerHtml = ds.Tables[0].Rows[1]["Description"].ToString(); imgDogservice.ImageUrl = Session["HomePath"] + "StoreData/HomeServices/" + ds.Tables[0].Rows[1]["ImageName"].ToString(); imgDogservice.ToolTip = ds.Tables[0].Rows[1]["Description"].ToString(); } }
public ActionResult Manager(int?productCategoryId, string SortBy, bool?SortAscending, bool returnToFrontEnd = false) { StoreFront storeFront = CurrentStoreFrontOrThrow; IQueryable <Product> query = null; if (!productCategoryId.HasValue) { ProductCategory firstCategory = storeFront.ProductCategories.AsQueryable().ApplyDefaultSort().FirstOrDefault(); if (firstCategory != null) { productCategoryId = firstCategory.ProductCategoryId; } } if (productCategoryId.HasValue && productCategoryId.Value != 0) { query = storeFront.Products.Where(p => p.ProductCategoryId == productCategoryId.Value).AsQueryable(); } else { query = storeFront.Products.AsQueryable(); } IOrderedQueryable <Product> products = query.ApplySort(this, SortBy, SortAscending); CatalogAdminViewModel viewModel = this.CatalogAdminViewModel; viewModel.UpdateSortedProducts(products); viewModel.FilterProductCategoryId = productCategoryId; viewModel.SortBy = SortBy; viewModel.SortAscending = SortAscending; viewModel.ReturnToFrontEnd = returnToFrontEnd; ViewData.Add("ReturnToFrontEnd", returnToFrontEnd); return(View("Manager", this.CatalogAdminViewModel)); }
/* Region is use to bind all pet information from database fro this we need pet type cat or dog */ private void BindGrid(string PetType) { StoreFront ObjStoreFront = new StoreFront(); DataSet ds = new DataSet(); DataTable dt = new DataTable(); DataView dv = new DataView(); ds = ObjStoreFront.GetBreed(PetType, Request.QueryString["SearchFor"].ToString(), Request.QueryString["SearchText"].ToString()); ddlSearch.SelectedValue = Request.QueryString["SearchFor"].ToString(); txtSearch.Text = Request.QueryString["SearchText"].ToString(); if (ds.Tables[0].Rows.Count > 0) { gdvBreed.Visible = true; btnDelete.Visible = true; btnStatus.Visible = true; //lblNorec.Visible = false; dt = ds.Tables[0]; dv = dt.DefaultView; if ((SortExpression != string.Empty) && (SortDirection != string.Empty)) { dv.Sort = SortExpression + " " + SortDirection; } gdvBreed.DataSource = dv; gdvBreed.DataBind(); CheckAll(); check(); Utility.Setserial(gdvBreed, "srno"); divSelectPet.Visible = true; btnExport.Visible = true; btnImport.Visible = true; divsearch.Visible = true; } else { divsearch.Visible = false; divSelectPet.Visible = false; //lblNorec.Visible = true; btnDelete.Visible = false; btnNew.Visible = true; btnStatus.Visible = false; gdvBreed.Visible = false; ErrMessage("Sorry, No records found."); if ((Convert.ToInt32(ddlSearch.SelectedIndex) > 0) && (txtSearch.Text != "")) { txtSearch.Text = ""; ddlSearch.SelectedIndex = 0; lnkNorec.Visible = true; btnNew.Visible = false; // btnAdd.Visible = false; btnExport.Visible = false; btnImport.Visible = false; divSelectPet.Visible = false; //lblMsg.Visible = true; ErrMessage("Sorry, No records found."); } } }
public GStoreEFDbContext(string userName, StoreFront cachedStoreFront, StoreFrontConfiguration cachedstoreFrontConfig, UserProfile cachedUserProfile) : base("name=GStoreWeb.Properties.Settings.GStoreDB") { this.UserName = userName; this.CachedStoreFront = cachedStoreFront; this.CachedStoreFrontConfig = cachedstoreFrontConfig; this.CachedUserProfile = cachedUserProfile; }
/// <summary> /// Note: Handles null storefront with system default message /// </summary> /// <param name="storeFront"></param> /// <param name="code"></param> /// <param name="uri"></param> /// <returns></returns> public static string AddPhoneNumberMessage(StoreFront storeFront, string code, Uri uri) { string messageBody = "Your security code is: " + code + " \n"; if (storeFront != null) { messageBody += "\n" + storeFront.OutgoingMessageSignature(); } messageBody += "\n\n" + Settings.IdentityTwoFactorSignature; return messageBody; }
public AdminMenuViewModel(StoreFront storeFront, UserProfile userProfile, string currentArea) { this.UserProfile = userProfile; if (currentArea.ToLower() != "blogadmin") { this.ShowBlogAdminLink = storeFront.ShowBlogAdminLink(userProfile); } if (currentArea.ToLower() != "catalogadmin") { this.ShowCatalogAdminLink = storeFront.ShowCatalogAdminLink(userProfile); } if (currentArea.ToLower() != "orderadmin") { this.ShowOrderAdminLink = storeFront.ShowOrderAdminLink(userProfile); } if (currentArea.ToLower() != "storeadmin") { this.ShowStoreAdminLink = storeFront.ShowStoreAdminLink(userProfile); } if (currentArea.ToLower() != "systemadmin") { this.ShowSystemAdminLink = userProfile.AspNetIdentityUserIsInRoleSystemAdmin(); } }
/// <summary> /// Uses Category.UrlName to prevent dupes /// </summary> private static ProductCategory CreateSeedProductCategory(this IGstoreDb storeDb, string name, string urlName, int order, bool hideInMenuIfEmpty, ProductCategory parentProductCategory, StoreFront storeFront, bool linkRandomImage, bool returnCategoryIfExists) { if (storeFront.ProductCategories.Any(pc => pc.UrlName.ToLower() == urlName.ToLower())) { if (returnCategoryIfExists) { return storeFront.ProductCategories.Single(pc => pc.UrlName.ToLower() == urlName.ToLower()); } return null; } ProductCategory category = storeDb.ProductCategories.Create(); category.SetDefaultsForNew(storeFront); category.Name = name; category.UrlName = urlName.FixUrlName(); category.Order = order; category.HideInMenuIfEmpty = hideInMenuIfEmpty; if (parentProductCategory != null) { category.ParentCategory = parentProductCategory; } if (linkRandomImage) { category.ImageName = category.RandomImageName(); } storeDb.ProductCategories.Add(category); storeDb.SaveChangesEx(true, false, false, false); return category; }
/// <summary> /// Not dupe-safe /// </summary> private static UserProfile CreateSeedUserProfile(this IGstoreDb storeDb, StoreFront storeFront, string userId, string userName, string email, string fullName, string addressLine1, string addressLine2, string city, string state, string postalCode, CountryCodeEnum countryCode) { UserProfile profile = storeDb.UserProfiles.Create(); profile.UserId = userId; profile.StoreFrontId = storeFront.StoreFrontId; profile.ClientId = storeFront.ClientId; profile.AllowUsersToSendSiteMessages = true; profile.Email = email; profile.EntryDateTime = DateTime.UtcNow; profile.EntryRawUrl = ""; profile.EntryReferrer = ""; profile.EntryUrl = ""; profile.FullName = fullName; profile.NotifyAllWhenLoggedOn = true; profile.NotifyOfSiteUpdatesToEmail = true; profile.SendMoreInfoToEmail = false; profile.SendSiteMessagesToEmail = true; profile.SendSiteMessagesToSms = false; profile.SubscribeToNewsletterEmail = true; profile.AddressLine1 = addressLine1; profile.AddressLine2 = addressLine2; profile.City = city; profile.State = state; profile.PostalCode = postalCode; profile.CountryCode = countryCode; profile.UserName = userName; profile.IsPending = false; profile.Order = 100; profile.StartDateTimeUtc = DateTime.UtcNow.AddMinutes(-1); profile.EndDateTimeUtc = DateTime.UtcNow.AddYears(100); storeDb.UserProfiles.Add(profile); storeDb.SaveChangesEx(true, false, false, false); return profile; }
/// <summary> /// Not dupe-safe /// </summary> private static StoreFrontConfiguration CreateSeedStoreFrontConfig(this IGstoreDb storeDb, StoreFront storeFront, string storeFrontName, string storeFrontFolder, UserProfile adminProfile, Theme selectedTheme) { if (storeFront == null) { throw new ArgumentNullException("storeFront"); } StoreFrontConfiguration storeFrontConfig = storeDb.StoreFrontConfigurations.Create(); storeFrontConfig.StoreFront = storeFront; storeFrontConfig.StoreFrontId = storeFront.StoreFrontId; storeFrontConfig.Name = storeFrontName; storeFrontConfig.ConfigurationName = "Default"; storeFrontConfig.Folder = storeFrontFolder; storeFrontConfig.IsPending = false; storeFrontConfig.StartDateTimeUtc = DateTime.UtcNow.AddSeconds(-1); storeFrontConfig.EndDateTimeUtc = DateTime.UtcNow.AddYears(100); storeFrontConfig.Client = storeFront.Client; storeFrontConfig.ClientId = storeFront.ClientId; storeFrontConfig.Order = storeFront.StoreFrontConfigurations.Count == 0 ? 100 : storeFront.StoreFrontConfigurations.Max(sf => sf.Order) + 10; storeFrontConfig.TimeZoneId = storeFront.Client.TimeZoneId; storeFrontConfig.AccountAdmin = adminProfile; storeFrontConfig.RegisteredNotify = adminProfile; storeFrontConfig.WelcomePerson = adminProfile; storeFrontConfig.OrderAdmin = adminProfile; storeFrontConfig.MetaApplicationName = storeFrontName; storeFrontConfig.MetaApplicationTileColor = "#880088"; storeFrontConfig.MetaDescription = "New GStore Storefront " + storeFrontName; storeFrontConfig.MetaKeywords = "GStore Storefront " + storeFrontName; storeFrontConfig.AdminTheme = selectedTheme; storeFrontConfig.AccountTheme = selectedTheme; storeFrontConfig.ProfileTheme = selectedTheme; storeFrontConfig.NotificationsTheme = selectedTheme; storeFrontConfig.CatalogTheme = selectedTheme; storeFrontConfig.CatalogAdminTheme = selectedTheme; storeFrontConfig.DefaultNewPageTheme = selectedTheme; storeFrontConfig.CatalogPageInitialLevels = 6; storeFrontConfig.CatalogTitle = storeFrontConfig.Name + " Catalog"; storeFrontConfig.CatalogLayout = CatalogLayoutEnum.SimpleBlocked; storeFrontConfig.CatalogHeaderHtml = null; storeFrontConfig.CatalogFooterHtml = null; storeFrontConfig.CatalogRootListTemplate = CategoryListTemplateEnum.Default; storeFrontConfig.CatalogRootHeaderHtml = null; storeFrontConfig.CatalogRootFooterHtml = null; storeFrontConfig.CatalogDefaultBottomDescriptionCaption = null; storeFrontConfig.CatalogDefaultNoProductsMessageHtml = null; storeFrontConfig.CatalogDefaultProductBundleTypePlural = null; storeFrontConfig.CatalogDefaultProductBundleTypeSingle = null; storeFrontConfig.CatalogDefaultProductTypePlural = null; storeFrontConfig.CatalogDefaultProductTypeSingle = null; storeFrontConfig.CatalogDefaultSampleAudioCaption = null; storeFrontConfig.CatalogDefaultSampleDownloadCaption = null; storeFrontConfig.CatalogDefaultSampleImageCaption = null; storeFrontConfig.CatalogDefaultSummaryCaption = null; storeFrontConfig.CatalogDefaultTopDescriptionCaption = null; storeFrontConfig.NavBarCatalogMaxLevels = 6; storeFrontConfig.NavBarItemsMaxLevels = 6; storeFrontConfig.CatalogCategoryColLg = 3; storeFrontConfig.CatalogCategoryColMd = 4; storeFrontConfig.CatalogCategoryColSm = 6; storeFrontConfig.CatalogProductColLg = 2; storeFrontConfig.CatalogProductColMd = 3; storeFrontConfig.CatalogProductColSm = 6; storeFrontConfig.CatalogProductBundleColLg = 3; storeFrontConfig.CatalogProductBundleColMd = 4; storeFrontConfig.CatalogProductBundleColSm = 6; storeFrontConfig.CatalogProductBundleItemColLg = 3; storeFrontConfig.CatalogProductBundleItemColMd = 4; storeFrontConfig.CatalogProductBundleItemColSm = 6; storeFrontConfig.BlogTheme = selectedTheme; storeFrontConfig.BlogThemeId = selectedTheme.ThemeId; storeFrontConfig.BlogAdminTheme = selectedTheme; storeFrontConfig.BlogAdminThemeId = selectedTheme.ThemeId; storeFrontConfig.ChatTheme = selectedTheme; storeFrontConfig.ChatThemeId = selectedTheme.ThemeId; storeFrontConfig.ChatEnabled = true; storeFrontConfig.ChatRequireLogin = false; storeFrontConfig.HtmlFooter = storeFrontName; storeFrontConfig.HomePageUseCatalog = true; storeFrontConfig.HomePageUseBlog = false; storeFrontConfig.ShowBlogInMenu = false; storeFrontConfig.ShowAboutGStoreMenu = true; storeFrontConfig.NavBarShowRegisterLink = true; storeFrontConfig.NavBarRegisterLinkText = "Sign-Up"; storeFrontConfig.AccountLoginShowRegisterLink = true; storeFrontConfig.AccountLoginRegisterLinkText = "Sign-up"; if (HttpContext.Current == null) { storeFrontConfig.PublicUrl = "http://localhost:55520/"; } else { Uri url = HttpContext.Current.Request.Url; string publicUrl = "http://" + url.Host; if (!url.IsDefaultPort) { publicUrl += ":" + url.Port; } publicUrl += HttpContext.Current.Request.ApplicationPath; storeFrontConfig.PublicUrl = publicUrl; } storeFrontConfig.ApplyDefaultCartConfig(); storeFrontConfig.ApplyDefaultCheckoutConfig(); storeFrontConfig.ApplyDefaultOrdersConfig(); storeFrontConfig.ApplyDefaultPaymentMethodConfig(); storeFrontConfig.CheckoutTheme = selectedTheme; storeFrontConfig.OrdersTheme = selectedTheme; storeFrontConfig.CatalogTheme = selectedTheme; storeFrontConfig.OrderAdminTheme = selectedTheme; storeDb.StoreFrontConfigurations.Add(storeFrontConfig); storeDb.SaveChangesEx(true, false, false, false); return storeFrontConfig; }
/// <summary> /// Checks an individual permission for a user and store front, used by other functions, no direct calls /// </summary> /// <param name="userProfile"></param> /// <param name="storeFront"></param> /// <param name="action"></param> /// <returns></returns> private static bool CheckSinglePermission(UserProfile userProfile, StoreFront storeFront, GStoreAction action) { if (storeFront == null) { return false; } return userProfile.ClientUserRoles.AsQueryable() .WhereIsActiveAndIsInScope(storeFront) .Any(cur => cur.ClientRole.ClientRoleActions.AsQueryable().WhereIsActive().Where(cra => cra.GStoreActionId == action).Any()); }
/// <summary> /// Creates seed discounts. /// Does not create dupes. Uses Discount.Code to prevent dupes. /// </summary> public static List<Discount> CreateSeedDiscounts(this IGstoreDb storeDb, StoreFront storeFront) { List<Discount> newDiscounts = new List<Discount>(); Discount test1 = storeDb.CreateSeedDiscount("test1", 0, null, false, 0, 0, 10, storeFront); Discount test2 = storeDb.CreateSeedDiscount("test2", 0, null, false, 0, 0, 10, storeFront); Discount test3 = storeDb.CreateSeedDiscount("test3", 0, null, false, 0, 0, 10, storeFront); if (test1 != null) { newDiscounts.Add(test1); } if (test2 != null) { newDiscounts.Add(test2); } if (test3 != null) { newDiscounts.Add(test3); } return newDiscounts; }
public void FillListsIfEmpty(Client client, StoreFront storeFront) { }
/// <summary> /// Uses ProductBundle.UrlName to prevent dupes /// </summary> private static ProductBundle CreateSeedProductBundle(this IGstoreDb storeDb, string name, string urlName, int order, int maxQuantityPerOrder, bool linkRandomImage, ProductCategory category, StoreFront storeFront, bool availableForPurchase, bool returnProductBundleIfExists, bool updateCategoryCounts) { if (storeFront.ProductBundles.Any(b => b.UrlName.ToLower() == urlName.ToLower())) { if (returnProductBundleIfExists) { return storeFront.ProductBundles.Single(b => b.UrlName.ToLower() == urlName.ToLower()); } return null; } ProductBundle productBundle = storeDb.ProductBundles.Create(); productBundle.Client = storeFront.Client; productBundle.StoreFront = storeFront; productBundle.Name = name; if (!urlName.IsValidUrlName()) { urlName = urlName.FixUrlName(); } productBundle.UrlName = urlName; productBundle.Order = order; productBundle.MaxQuantityPerOrder = maxQuantityPerOrder; productBundle.IsPending = false; productBundle.StartDateTimeUtc = DateTime.UtcNow.AddMinutes(-1); productBundle.EndDateTimeUtc = DateTime.UtcNow.AddYears(100); productBundle.Category = category; productBundle.SummaryCaption = "Summary for " + productBundle.Name; productBundle.SummaryHtml = "Summary has not been entered yet for " + productBundle.Name; productBundle.TopDescriptionCaption = "Description for " + productBundle.Name; productBundle.TopDescriptionHtml = "Description has not been entered yet for " + productBundle.Name; productBundle.TopLinkLabel = null; productBundle.TopLinkHref = null; productBundle.BottomDescriptionCaption = "Details for " + productBundle.Name; productBundle.BottomDescriptionHtml = "Details have not been entered yet for " + productBundle.Name; productBundle.ProductTypeSingle = null; productBundle.ProductTypePlural = null; productBundle.BottomLinkLabel = null; productBundle.BottomLinkHref = null; productBundle.ProductBundleDetailTemplate = ProductBundleDetailTemplateEnum.Default; productBundle.AvailableForPurchase = availableForPurchase; productBundle.ForAnonymousOnly = false; productBundle.ForRegisteredOnly = false; if (linkRandomImage) { productBundle.ImageName = productBundle.RandomImageName(); } storeDb.ProductBundles.Add(productBundle); storeDb.SaveChangesEx(true, false, false, updateCategoryCounts); return productBundle; }
/// <summary> /// Dupe-safe uses pageId to prevent dupes /// Note: There may be some circumstances when a page may have multiple NavBarItems this will handle it by returning the first match /// </summary> private static NavBarItem CreateSeedNavBarItemForPage(this IGstoreDb storeDb, string name, int pageId, bool forRegisteredOnly, NavBarItem parentNavBarItem, StoreFront storeFront, bool returnPageIfExists) { if (storeFront.NavBarItems.Any(n => n.PageId.HasValue && n.PageId.Value == pageId)) { if (returnPageIfExists) { return storeFront.NavBarItems.First(n => n.PageId.HasValue && n.PageId.Value == pageId); } return null; } NavBarItem newItem = storeDb.NavBarItems.Create(); newItem.SetDefaultsForNew(storeFront); newItem.IsPage = true; newItem.PageId = pageId; newItem.Name = name; newItem.ForRegisteredOnly = forRegisteredOnly; if (parentNavBarItem != null) { newItem.ParentNavBarItem = parentNavBarItem; } storeDb.NavBarItems.Add(newItem); storeDb.SaveChangesEx(true, false, false, false); return newItem; }
/// <summary> /// Not dupe-safe /// </summary> private static NavBarItem CreateSeedNavBarItemForAction(this IGstoreDb storeDb, string name, int order, string action, string controller, string area, bool forRegisteredOnly, NavBarItem parentNavBarItem, StoreFront storeFront) { NavBarItem newItem = storeDb.NavBarItems.Create(); newItem.Client = storeFront.Client; newItem.StoreFront = storeFront; newItem.IsAction = true; newItem.Action = action; newItem.Controller = controller; newItem.Area = area; newItem.Name = name; newItem.Order = order; newItem.IsPending = false; newItem.StartDateTimeUtc = DateTime.UtcNow.AddMinutes(-1); newItem.EndDateTimeUtc = DateTime.UtcNow.AddYears(100); newItem.ForRegisteredOnly = forRegisteredOnly; newItem.UseDividerAfterOnMenu = false; newItem.UseDividerBeforeOnMenu = true; if (parentNavBarItem != null) { newItem.ParentNavBarItem = parentNavBarItem; } storeDb.NavBarItems.Add(newItem); storeDb.SaveChangesEx(true, false, false, false); return newItem; }
public void FillListsIfEmpty(Client client, StoreFront storeFront) { if (this.StoreFront == null) { this.StoreFront = storeFront; this.StoreFrontId = storeFront.StoreFrontId; } if (this.PageTemplateSelectList == null) { this.PageTemplateSelectList = client.PageTemplates.AsQueryable().ToSelectList(this.PageTemplateId).ToList(); } if (this.ThemeSelectList == null) { this.ThemeSelectList = client.Themes.AsQueryable().ToSelectList(this.ThemeId).ToList(); } if (this.WebFormSelectList == null) { this.WebFormSelectList = client.WebForms.AsQueryable().ToSelectListWithNull(this.WebFormId).ToList(); } if (this.WebFormSuccessPageSelectList == null) { this.WebFormSuccessPageSelectList = storeFront.Pages.AsQueryable().ToSelectListWithNull(this.WebFormSuccessPageId).ToList(); } }
/// <summary> /// Returns a list of ClientRoleAction for a user. Note: This is for database mapping only, identity roles like systemadmin will only return roles explicitly linked /// </summary> /// <param name="db"></param> /// <param name="userProfile"></param> /// <param name="storeFront"></param> /// <returns></returns> public static List<ClientRoleAction> Authorization_ListDefinedRoleActions(this IGstoreDb db, UserProfile userProfile, StoreFront storeFront) { //returns true if there is an active ClientUserRoleAction return db.ClientRoleActions .Where(cra => cra.ClientRole.ClientUserRoles.AsQueryable().WhereIsActiveAndIsInScope(storeFront).Any(cur => cur.UserProfileId == userProfile.UserProfileId)) .WhereIsActive() .ToList(); }
/// <summary> /// Checks Multiple StoreFront permissions for the specified user. /// If allowAnyMatch is true, this is an OR test for each option. If allowAnyMatch = false, this is an AND test for all options /// </summary> /// <param name="userProfile"></param> /// <param name="storeFront"></param> /// <param name="allowAnyMatch">If allowAnyMatch is true, this is an OR test for each option. If allowAnyMatch = false, this is an AND test for all options</param> /// <param name="actions"></param> /// <returns></returns> public static bool Authorization_IsAuthorized(this UserProfile userProfile, StoreFront storeFront, bool allowAnyMatch, params Identity.GStoreAction[] actions) { return storeFront.Authorization_IsAuthorized(userProfile, allowAnyMatch, actions); }
/// <summary> /// Checks a single StoreFront permission for the specified user. /// </summary> /// <param name="userProfile"></param> /// <param name="storeFront"></param> /// <param name="action"></param> /// <returns></returns> public static bool Authorization_IsAuthorized(this UserProfile userProfile, StoreFront storeFront, Identity.GStoreAction action) { return storeFront.Authorization_IsAuthorized(userProfile, action); }
/// <summary> /// Uses productBundle.ProductBundleId and Product.ProductId to prevent dupes /// </summary> private static ProductBundleItem CreateSeedProductBundleItem(this IGstoreDb storeDb, ProductBundle productBundle, Product product, int order, StoreFront storeFront, int quantity, decimal baseUnitPrice, decimal baseListPrice, bool returnProductBundleItemIfExists, bool updateCategoryCounts) { if (productBundle.ProductBundleItems.Any(i => i.ProductId == product.ProductId)) { if (returnProductBundleItemIfExists) { return productBundle.ProductBundleItems.Single(i => i.ProductId == product.ProductId); } return null; } ProductBundleItem productBundleItem = storeDb.ProductBundleItems.Create(); productBundleItem.Client = storeFront.Client; productBundleItem.StoreFront = storeFront; productBundleItem.ProductBundleId = productBundle.ProductBundleId; productBundleItem.ProductId = product.ProductId; productBundleItem.BaseListPrice = baseListPrice; productBundleItem.BaseUnitPrice = baseUnitPrice; productBundleItem.Quantity = quantity; productBundleItem.Order = order; productBundleItem.ProductBundleId = productBundle.ProductBundleId; productBundleItem.IsPending = false; productBundleItem.StartDateTimeUtc = DateTime.UtcNow.AddMinutes(-1); productBundleItem.EndDateTimeUtc = DateTime.UtcNow.AddYears(100); storeDb.ProductBundleItems.Add(productBundleItem); storeDb.SaveChangesEx(true, false, false, updateCategoryCounts); return productBundleItem; }
protected void LoadValues(StoreFront storeFront, UserProfile userProfile, WebForm webForm) { if (webForm == null) { return; } this.WebForm = webForm; this.Client = webForm.Client; this.ClientId = (webForm.Client == null ? 0 : webForm.ClientId); this.CreateDateTimeUtc = webForm.CreateDateTimeUtc; this.CreatedBy = webForm.CreatedBy; this.CreatedBy_UserProfileId = webForm.CreatedBy_UserProfileId; this.Description = webForm.Description; this.DisplayTemplateName = webForm.DisplayTemplateName; this.EndDateTimeUtc = webForm.EndDateTimeUtc; this.FieldMdColSpan = webForm.FieldMdColSpan; this.FormFooterAfterSubmitHtml = webForm.FormFooterAfterSubmitHtml; this.FormFooterBeforeSubmitHtml = webForm.FormFooterBeforeSubmitHtml; this.FormHeaderHtml = webForm.FormHeaderHtml; this.IsPending = webForm.IsPending; this.LabelMdColSpan = webForm.LabelMdColSpan; this.Name = webForm.Name; this.Order = webForm.Order; this.Pages = webForm.Pages; this.StartDateTimeUtc = webForm.StartDateTimeUtc; this.SubmitButtonClass = webForm.SubmitButtonClass; this.SubmitButtonText = webForm.SubmitButtonText; this.Title = webForm.Title; this.UpdateDateTimeUtc = webForm.UpdateDateTimeUtc; this.UpdatedBy = webForm.UpdatedBy; this.UpdatedBy_UserProfileId = webForm.UpdatedBy_UserProfileId; this.WebFormFields = webForm.WebFormFields; this.WebFormId = webForm.WebFormId; this.WebFormResponses = webForm.WebFormResponses; this._webFormFieldViewModels = null; }
/// <summary> /// Dupe-safe uses Discount.Code to prevent dupes /// </summary> private static Discount CreateSeedDiscount(this IGstoreDb storeDb, string code, decimal flatDiscount, Product freeProductOrNull, bool freeShipping, int maxUsesZeroForNoLimit, decimal minSubTotal, decimal percentOff, StoreFront storeFront) { if (storeFront.Discounts.Any(d => d.Code.ToLower() == code.ToLower())) { return null; } Discount record = storeDb.Discounts.Create(); record.Client = storeFront.Client; record.StoreFront = storeFront; record.Code = code; record.FlatDiscount = flatDiscount; record.FreeProduct = freeProductOrNull; record.FreeShipping = freeShipping; record.MaxUses = maxUsesZeroForNoLimit; record.MinSubtotal = minSubTotal; record.Order = (storeDb.Discounts.IsEmpty() ? 100 : storeDb.Discounts.All().Max(d => d.Order) + 10); record.PercentOff = percentOff; record.UseCount = 0; record.IsPending = false; record.StartDateTimeUtc = DateTime.UtcNow.AddMinutes(-1); record.EndDateTimeUtc = DateTime.UtcNow.AddYears(100); storeDb.Discounts.Add(record); storeDb.SaveChangesEx(true, false, false, false); return record; }
protected void ProcessFileUploads(CategoryEditAdminViewModel viewModel, StoreFront storeFront) { string virtualFolder = storeFront.CatalogCategoryContentVirtualDirectoryToMap(Request.ApplicationPath); string fileFolder = Server.MapPath(virtualFolder); if (!System.IO.Directory.Exists(fileFolder)) { System.IO.Directory.CreateDirectory(fileFolder); } HttpPostedFileBase imageFile = Request.Files["ImageName_File"]; if (imageFile != null && imageFile.ContentLength != 0) { string newFileName = imageFile.FileNameNoPath(); if (!string.IsNullOrEmpty(Request.Form["ImageName_ChangeFileName"])) { newFileName = viewModel.UrlName + "_Image." + imageFile.FileName.FileExtension(); } try { imageFile.SaveAs(fileFolder + "\\" + newFileName); } catch (Exception ex) { throw new ApplicationException("Error saving category image file '" + imageFile.FileName + "' as '" + newFileName + "'", ex); } viewModel.ImageName = newFileName; AddUserMessage("Image Uploaded!", "Category Image '" + imageFile.FileName.ToHtml() + "' " + imageFile.ContentLength.ToByteString() + " was saved as '" + newFileName + "'", UserMessageType.Success); } }
public static void SetDefaultsForNew(this ProductCategory productCategory, StoreFront storeFront) { if (storeFront == null) { throw new ArgumentNullException("storeFront"); } productCategory.ClientId = storeFront.ClientId; productCategory.Client = storeFront.Client; productCategory.StoreFrontId = storeFront.StoreFrontId; productCategory.StoreFront = storeFront; if (storeFront.ProductCategories == null || storeFront.ProductCategories.Count == 0) { productCategory.Name = "New Category"; productCategory.Order = 100; } else { productCategory.Order = (storeFront.ProductCategories.Max(nb => nb.Order) + 10); productCategory.Name = "New Category " + productCategory.Order; } productCategory.UrlName = productCategory.Name.Replace(' ', '_'); productCategory.ImageName = null; productCategory.ForRegisteredOnly = false; productCategory.UseDividerBeforeOnMenu = true; productCategory.UseDividerAfterOnMenu = false; productCategory.ShowInMenu = true; productCategory.AllowChildCategoriesInMenu = true; productCategory.ShowTop10ChildProductsInMenu = false; productCategory.HideInMenuIfEmpty = false; productCategory.ShowInCatalogIfEmpty = true; productCategory.DisplayForDirectLinks = true; productCategory.ProductTypeSingle = null; productCategory.ProductTypePlural = null; productCategory.BundleTypeSingle = null; productCategory.BundleTypePlural = null; productCategory.IsPending = false; productCategory.EndDateTimeUtc = DateTime.UtcNow.AddYears(100); productCategory.StartDateTimeUtc = DateTime.UtcNow.AddMinutes(-1); }
public static IQueryable<ClientUserRole> WhereIsActiveAndIsInScope(this IQueryable<ClientUserRole> query, StoreFront storeFront) { return query.WhereIsActive() .Where(cur => cur.ClientId == storeFront.ClientId && (cur.ScopeStoreFront == null || cur.ScopeStoreFrontId == storeFront.StoreFrontId)); }
protected void ProcessFileUploads(ProductEditAdminViewModel viewModel, StoreFront storeFront) { //todo: temporary file process string virtualFolder = storeFront.CatalogProductContentVirtualDirectoryToMap(Request.ApplicationPath); string fileFolder = Server.MapPath(virtualFolder); if (!System.IO.Directory.Exists(fileFolder)) { System.IO.Directory.CreateDirectory(fileFolder); } HttpPostedFileBase imageFile = Request.Files["ImageName_File"]; if (imageFile != null && imageFile.ContentLength != 0) { string newFileName = imageFile.FileNameNoPath(); if (!string.IsNullOrEmpty(Request.Form["ImageName_ChangeFileName"])) { newFileName = viewModel.UrlName + "_Image." + imageFile.FileName.FileExtension(); } try { imageFile.SaveAs(fileFolder + "\\" + newFileName); } catch (Exception ex) { throw new ApplicationException("Error saving product image file '" + imageFile.FileName + "' as '" + newFileName + "'", ex); } viewModel.ImageName = newFileName; AddUserMessage("Image Uploaded!", "Product Image '" + imageFile.FileName.ToHtml() + "' " + imageFile.ContentLength.ToByteString() + " was saved as '" + newFileName + "'", UserMessageType.Success); } HttpPostedFileBase digitalDownloadFile = Request.Files["DigitalDownloadFileName_File"]; if (digitalDownloadFile != null && digitalDownloadFile.ContentLength != 0) { string digitalDownloadVirtualFolder = storeFront.ProductDigitalDownloadVirtualDirectoryToMap(Request.ApplicationPath); string digitalDownloadFileFolder = Server.MapPath(digitalDownloadVirtualFolder); if (!System.IO.Directory.Exists(digitalDownloadFileFolder)) { System.IO.Directory.CreateDirectory(digitalDownloadFileFolder); } string newFileName = digitalDownloadFile.FileNameNoPath(); if (!string.IsNullOrEmpty(Request.Form["DigitalDownloadFileName_ChangeFileName"])) { newFileName = viewModel.UrlName + "_DigitalDownload." + digitalDownloadFile.FileName.FileExtension(); } try { digitalDownloadFile.SaveAs(digitalDownloadFileFolder + "\\" + newFileName); } catch (Exception ex) { throw new ApplicationException("Error saving product digital download file '" + digitalDownloadFile.FileName + "' as '" + newFileName + "'", ex); } viewModel.DigitalDownloadFileName = newFileName; AddUserMessage("Digital Download Uploaded!", "Product Digital Download File '" + digitalDownloadFile.FileName.ToHtml() + "' " + digitalDownloadFile.ContentLength.ToByteString() + " was saved as '" + newFileName + "'", UserMessageType.Success); } HttpPostedFileBase sampleAudioFile = Request.Files["SampleAudioFileName_File"]; if (sampleAudioFile != null && sampleAudioFile.ContentLength != 0) { string newFileName = digitalDownloadFile.FileNameNoPath(); if (!string.IsNullOrEmpty(Request.Form["SampleAudioFileName_ChangeFileName"])) { newFileName = viewModel.UrlName + "_SampleAudio." + sampleAudioFile.FileName.FileExtension(); } try { sampleAudioFile.SaveAs(fileFolder + "\\" + newFileName); } catch (Exception ex) { throw new ApplicationException("Error saving product sample audio file '" + sampleAudioFile.FileName + "' as '" + newFileName + "'", ex); } viewModel.SampleAudioFileName = newFileName; AddUserMessage("Sample Audio Uploaded!", "Product Sample Audio File '" + sampleAudioFile.FileName.ToHtml() + "' " + sampleAudioFile.ContentLength.ToByteString() + " was saved as '" + newFileName + "'", UserMessageType.Success); } HttpPostedFileBase sampleDownloadFile = Request.Files["SampleDownloadFileName_File"]; if (sampleDownloadFile != null && sampleDownloadFile.ContentLength != 0) { string newFileName = sampleDownloadFile.FileNameNoPath(); if (!string.IsNullOrEmpty(Request.Form["SampleAudioFileName_ChangeFileName"])) { newFileName = viewModel.UrlName + "_SampleDownload." + sampleDownloadFile.FileName.FileExtension(); } try { sampleDownloadFile.SaveAs(fileFolder + "\\" + newFileName); } catch (Exception ex) { throw new ApplicationException("Error saving product sample download file '" + sampleDownloadFile.FileName + "' as '" + newFileName + "'", ex); } viewModel.SampleDownloadFileName = newFileName; AddUserMessage("Sample Download File Uploaded!", "Product Sample Download File '" + sampleDownloadFile.FileName.ToHtml() + "' " + sampleDownloadFile.ContentLength.ToByteString() + " was saved as '" + newFileName + "'", UserMessageType.Success); } HttpPostedFileBase sampleImageFile = Request.Files["SampleImageFileName_File"]; if (sampleImageFile != null && sampleImageFile.ContentLength != 0) { string newFileName = sampleImageFile.FileNameNoPath(); if (!string.IsNullOrEmpty(Request.Form["SampleAudioFileName_ChangeFileName"])) { newFileName = viewModel.UrlName + "_SampleImage." + sampleImageFile.FileName.FileExtension(); } try { sampleImageFile.SaveAs(fileFolder + "\\" + newFileName); } catch (Exception ex) { throw new ApplicationException("Error saving product sample image file '" + sampleImageFile.FileName + "' as '" + newFileName + "'", ex); } viewModel.SampleImageFileName = newFileName; AddUserMessage("Sample Image File Uploaded!", "Sample Image File '" + sampleImageFile.FileName.ToHtml() + "' " + sampleImageFile.ContentLength.ToByteString() + " was saved as '" + newFileName + "'", UserMessageType.Success); } }
public static void SetDefaultsForNew(this UserProfile profile, Client client, StoreFront storeFront) { if (client != null) { profile.Client = client; profile.ClientId = client.ClientId; profile.TimeZoneId = client.TimeZoneId; } if (storeFront != null) { profile.StoreFront = storeFront; profile.StoreFrontId = storeFront.StoreFrontId; StoreFrontConfiguration storeFrontConfig = storeFront.CurrentConfigOrAny(); if (storeFrontConfig != null) { profile.TimeZoneId = storeFrontConfig.TimeZoneId; } } profile.EntryDateTime = DateTime.UtcNow; profile.IsPending = true; profile.EndDateTimeUtc = DateTime.UtcNow.AddYears(100); profile.StartDateTimeUtc = DateTime.UtcNow.AddMinutes(-1); }