public void RemoveProduct(string name) { ProductSection productSection = config.GetSection("products") as ProductSection; productSection.Products.Remove(name); config.Save(); }
public virtual ProductSection UpdateProductSection(ProductSection entity) { if (entity.IsTransient()) { return(entity); } ProductSection other = GetProductSection(entity.ProductId); if (entity.Equals(other)) { return(entity); } string sql = @"Update ProductSection set [SectionID]=@SectionID , [DisplayOrder]=@DisplayOrder , [CreatedOn]=@CreatedOn where ProductID=@ProductID" ; SqlParameter[] parameterArray = new SqlParameter[] { new SqlParameter("@ProductID", entity.ProductId) , new SqlParameter("@SectionID", entity.SectionId) , new SqlParameter("@DisplayOrder", entity.DisplayOrder) , new SqlParameter("@CreatedOn", entity.CreatedOn) }; SqlHelper.ExecuteNonQuery(this.ConnectionString, CommandType.Text, sql, parameterArray); return(GetProductSection(entity.ProductId)); }
public virtual ProductSection InsertProductSection(ProductSection entity) { ProductSection other = new ProductSection(); other = entity; if (entity.IsTransient()) { string sql = @"Insert into ProductSection ( [ProductID] ,[SectionID] ,[DisplayOrder] ,[CreatedOn] ) Values ( @ProductID , @SectionID , @DisplayOrder , @CreatedOn ); Select scope_identity()" ; SqlParameter[] parameterArray = new SqlParameter[] { new SqlParameter("@ProductID", entity.ProductId) , new SqlParameter("@SectionID", entity.SectionId) , new SqlParameter("@DisplayOrder", entity.DisplayOrder) , new SqlParameter("@CreatedOn", entity.CreatedOn) }; var identity = SqlHelper.ExecuteScalar(this.ConnectionString, CommandType.Text, sql, parameterArray); if (identity == DBNull.Value) { throw new DataException("Identity column was null as a result of the insert operation."); } return(GetProductSection(Convert.ToInt32(identity))); } return(entity); }
public CreateProductPresenter(IStateManager manager, ProductSection product) : base(manager) { IsFormCancelled = false; ProductSection = product; Form = (ISpecificProductView)FormFactory.CreateForm("SpecificProductForm", new object[] { this }); ((Form)Form).FormClosing += (sen, e) => Cancel(); Form.DisplayCategories(ProductSection.CategoryService.FindAll()); }
public SearchProductPresenter(IStateManager manager, WorkCompletedCallBack callBack) : base(manager) { Form = (ISearchProductView)FormFactory.CreateForm("SearchProductForm", new object[] { this }); ProductSection = new ProductSection(Form.ProductDataTable, this, Form); Form.SetSearchParams(ProductSection.GetSearchParameters()); ProductSection.UpdateVisibleProducts(); Callback = callBack; Form.Text = Title; }
public ProductWrapperList GetProducts() { ProductSection productSection = config.GetSection("products") as ProductSection; ProductWrapperList productList = new ProductWrapperList(); foreach (ProductElement element in productSection.Products) { productList.Add(new ProductWrapper(element.Name, element.Company, element.InstallPath, element.VirtualDirectoryRoot)); } return(productList); }
public void Delete(string Id) { ProductSection ProductSectionToDelete = productsections.Find(p => p.Id == Id); if (ProductSectionToDelete != null) { productsections.Remove(ProductSectionToDelete); } else { throw new Exception("Product no found"); } }
public ProductSection Find(string Id) { ProductSection ProductSection = productsections.Find(p => p.Id == Id); if (ProductSection != null) { return(ProductSection); } else { throw new Exception("Product Section no found"); } }
public void Update(ProductSection ProductSection) { ProductSection ProductSectionToUpdate = productsections.Find(p => p.Id == ProductSection.Id); if (ProductSectionToUpdate != null) { ProductSectionToUpdate = ProductSection; } else { throw new Exception("Product Section no found"); } }
public void LoginAsNobody(string baseUrl) { _driver.Navigate().GoToUrl(baseUrl); ProductSection.Click(); ProductSection.Clear(); // sending a single quote is not possible with the Chrome Driver, it sends two single quotes! ProductSection.SendKeys("nobody"); VaccumCleaners.Clear(); VaccumCleaners.SendKeys("blah"); LoginButton.Click(); }
public void OpenVaccumCleaners(string baseUrl) { _driver.Navigate().GoToUrl(baseUrl); ProductSection.Click(); ProductSection.Click(); //// sending a single quote is not possible with the Chrome Driver, it sends two single quotes! //ProductSection.SendKeys("admin'--"); VaccumCleaners.Click(); //VaccumCleaners.SendKeys("blah"); //LoginButton.Click(); }
public ActionResult Delete(string Id) { ProductSection ProductsectionToDelete = context.Find(Id); if (ProductsectionToDelete == null) { return(HttpNotFound()); } else { return(View(ProductsectionToDelete)); } }
public ActionResult Edit(string Id) { ProductSection Productsection = context.Find(Id); if (Productsection == null) { return(HttpNotFound()); } else { return(View(Productsection)); } }
public virtual ProductSection ProductSectionFromDataRow(DataRow dr) { if (dr == null) { return(null); } ProductSection entity = new ProductSection(); entity.ProductId = (System.Int32)dr["ProductID"]; entity.SectionId = (System.Int32)dr["SectionID"]; entity.DisplayOrder = (System.Int32)dr["DisplayOrder"]; entity.CreatedOn = (System.DateTime)dr["CreatedOn"]; return(entity); }
public ActionResult Create(ProductSection Productsection) { if (!ModelState.IsValid) { return(View(Productsection)); } else { context.Insert(Productsection); context.Commit(); return(RedirectToAction("Index")); } }
public ActionResult ConfirmDelete(string Id) { ProductSection ProductsectionToDelete = context.Find(Id); if (ProductsectionToDelete == null) { return(HttpNotFound()); } else { context.Delete(Id); return(RedirectToAction("Index")); } }
private static string getTextFromSettings(ProductSection section) { if (section.Settings == null || section.Type != ProductSectionType.Text) { return(null); } var settings = JsonConvert.DeserializeObject <ProductSectionTextSettings>(section.Settings); if (settings == null) { return(null); } return(settings.Text); }
public CreateCategoryPresenter(IStateManager manager, ProductSection productSection) : base(manager) { IsFormCancelled = false; Form = (IAddCategoryView)FormFactory.CreateForm("SpecificCategoryForm", new object[] { this }); ProductSection = productSection; var categories = ProductSection.CategoryService.FindAll(); categories.Insert(0, new Category { CategoryName = "ГЛАВНА!", Id = 0 }); Form.DisplayCategories(categories); Form.SelectedCategory = categories[0]; ((Form)Form).FormClosing += (e, s) => Cancel(); }
public void SaveProduct(string name, string company, string installPath, string virtualDirectoryRoot) { ProductSection productSection = config.GetSection("products") as ProductSection; ProductElement element = new ProductElement(); element.Name = name; element.Company = company; element.InstallPath = installPath; element.VirtualDirectoryRoot = virtualDirectoryRoot; // Add the product productSection.Products.Add(element); config.Save(); }
public override async Task <ObservableCollection <T> > RefreshObjectAsync <T>(string ItemsUrl) { Console.WriteLine("RefreshObjectAsync is running"); ObservableCollection <T> Items = new ObservableCollection <T>(); var uri = new Uri(string.Format(ItemsUrl, string.Empty)); try { var response = await _client.GetAsync(uri); if (response.IsSuccessStatusCode) { var content = await response.Content.ReadAsStringAsync(); JObject results = JObject.Parse(content); // get JSON result objects into a list IList <JToken> productSections = results["items"].Children().ToList(); IList <ProductSection> ProductSections = new ObservableCollection <ProductSection>(); foreach (JToken result in productSections) { // JToken.ToObject is a helper method that uses JsonSerializer internally JToken category = result["root"]; JToken product = result["element"]; ProductSection productSection = new ProductSection(); productSection.category = category.ToObject <Category>(); productSection.products = product.ToObject <ObservableCollection <Product> >(); //Console.WriteLine($"Category: {JsonConvert.SerializeObject(productSection.category)}"); //Console.WriteLine($"Product: {JsonConvert.SerializeObject(productSection.products)}"); ProductSections.Add(productSection); } ; //Items = JsonConvert.DeserializeObject<ObservableCollection<T>>(content); Items = (ObservableCollection <T>)ProductSections; Console.WriteLine("==>>RefreshObjectAsync successfully runned"); Console.WriteLine($"+ Data includes {Items.Count} elements"); } } catch (Exception ex) { Debug.WriteLine(@"\tERROR {0}", ex.Message); } return(Items); }
public EditProductPresenter(IStateManager manager, Product productToEdit, ProductSection product) : base(manager) { ProductToEdit = productToEdit; ProductSection = product; Form = (ISpecificProductView)FormFactory.CreateForm("SpecificProductForm", new object[] { this }); var categories = ProductSection.CategoryService.FindAll(); ((Form)Form).FormClosing += (e, s) => Cancel(); Form.ProductName = productToEdit.ProductName; Form.DisplayCategories(categories); Form.SelectedCategory = categories.FirstOrDefault(c => c.Id == productToEdit.CategoryId); Form.Quantity = productToEdit.Quantity; Form.ImportPrice = productToEdit.ImportPrice; Form.SellPrice = productToEdit.SellPrice; Form.IsVisible = productToEdit.IsVisible; }
public void Submit() { ProductToEdit.ProductName = Form.ProductName; ProductToEdit.CategoryId = Form.SelectedCategory.Id; ProductToEdit.IsVisible = Form.IsVisible; ProductToEdit.ImportPrice = Form.ImportPrice; ProductToEdit.SellPrice = Form.SellPrice; ProductToEdit.Quantity = Form.Quantity; try { ProductSection.EditProductAction(ProductToEdit); ProductSection.UpdateProducts(); Cancel(); } catch (ArgumentException e) { StateManager.Push(new ErrorPresenter(StateManager, e.Message, true)); } }
public static async Task <ProductSection> GetProductDownloadSectionsAsync(int productId, string userId, ApplicationDbContext db = null) { if (db == null) { db = ApplicationDbContext.Create(); } var today = DateTime.Now.Date; var items = await(from i in db.Items join it in db.ItemTypes on i.ItemTypeId equals it.Id join pi in db.ProductItems on i.Id equals pi.ItemId join ps in db.SubscriptionProducts on pi.ProductId equals ps.ProductId join us in db.UserSubscriptions on ps.SubscriptionId equals us.SubscriptionId where it.Title.Equals("Download") && pi.ProductId.Equals(productId) && us.UserId.Equals(userId) orderby i.PartId select new ProductItemRow { ItemId = i.Id, Description = i.Description, Title = i.Title, Link = i.Url, ImageUrl = i.ImageUrl, IsDownload = true, // <-- New ReleaseDate = DbFunctions.CreateDateTime( us.StartDate.Value.Year, us.StartDate.Value.Month, us.StartDate.Value.Day + i.WaitDays, 0, 0, 0), IsAvailable = DbFunctions.CreateDateTime(today.Year, today.Month, today.Day, 0, 0, 0) >= DbFunctions.CreateDateTime(us.StartDate.Value.Year, us.StartDate.Value.Month, us.StartDate.Value.Day + i.WaitDays, 0, 0, 0) }).ToListAsync(); var section = new ProductSection { Title = "Downloads", Items = items }; return(section); }
public ActionResult Edit(ProductSection product, string Id) { ProductSection ProductsectionToEdit = context.Find(Id); if (ProductsectionToEdit == null) { return(HttpNotFound()); } else { if (!ModelState.IsValid) { return(View(product)); } ProductsectionToEdit.Section = product.Section; context.Commit(); return(RedirectToAction("Index")); } }
public HomePresenter(IStateManager manager) : base(manager) { Form = (IHomeView) FormFactory.CreateForm("MainForm", new object[] {this}); //onClosingEvent to stop the application ((Form) Form).FormClosing += (sender, args) => ApplicationState.IsRunning = false; ProductSection = new ProductSection(Form.ProductDataTable, this, Form); SettingsSection = new SettingsSection(this); StateManager.EventManager.AddEvent(new Event( Config.EventListenerImmediate, CheckIsLoginHandler, GetStateManager().EventManager, true)); IsProductsDisplayed = false; Form.TabLabelText = Tab1LabelText; Form.SetSearchParams(ProductSection.GetSearchParameters()); if (!StateManager.UserSession.IsActive) //prevent any actions till login return; }
public void Submit() { var product = new Product { ProductName = Form.ProductName, CategoryId = Form.SelectedCategory.Id, IsVisible = Form.IsVisible, ImportPrice = Form.ImportPrice, SellPrice = Form.SellPrice, Quantity = Form.Quantity }; try { ProductSection.AddNewProductAction(product); ProductSection.UpdateProducts(); Cancel(); } catch (ArgumentException e) { StateManager.Push(new ErrorPresenter(StateManager, e.Message, true)); } }
public override void Update() { if (!IsFormShown) { Form.Show(); IsFormShown = true; } if (!IsProductsDisplayed && StateManager.UserSession.SessionEntity != null) { ProductSection.UpdateProducts(); IsProductsDisplayed = true; if (Roles.IsStandard(StateManager.UserSession.SessionEntity.Roles)) { Form.EnableOrDisableMaterialBtn("RevenueBtn", true); Form.EnableOrDisableMaterialBtn("InvoicesBtn", true); Form.EnableOrDisableMaterialBtn("ExpensesBtn", true); } Form.Text = $"Simple Warehouse, Потребител: {StateManager.UserSession.SessionEntity.Username} ({string.Join(",", StateManager.UserSession.SessionEntity.Roles.Select(r => r.RoleType.ToString()))})"; InitializeUserRequiredSections(); } }
public ProductSection UpdateProductSection(ProductSection entity) { return(_iProductSectionRepository.UpdateProductSection(entity)); }
public Task SaveProductSectionAsync(ProductSection item, bool isNewItem) { return(restService.SaveObjectAsync <ProductSection>(Constants.ProductSectionsUrl, item, isNewItem)); }
public ProductSection InsertProductSection(ProductSection entity) { return(_iProductSectionRepository.InsertProductSection(entity)); }