public ProductsView GetProductById(long Id, out string message) { ProductsView result = new ProductsView(); message = null; try { if (Id > 0) { var product = entities.v_Product.FirstOrDefault(w => w.ProductId == Id); if (product != null) { result = Helper.ConvertProductToProductView(product); } else { message = Resources.MSG_THE_PRODUCT_CATEGORY_HAS_NOT_FOUND; } } else { message = Resources.MSG_THE_PRODUCT_CATEGORY_HAS_NOT_FOUND; } } catch (Exception ex) { string subject = "Error " + SiteSetting.SiteName + " at GetProductCategoryById at ProductCategoryRepo at Model.Repository"; message = StringHelper.Parameters2ErrorString(ex, conn); MailHelper.SendMail(SiteSetting.EmailAdmin, subject, message); } return(result); }
/// <summary> /// Updates a Product /// Level: Logic /// </summary> /// <param name="ProductID">The Product ID</param> /// <param name="Name">The Product Name</param> /// <param name="Description">The Product Description</param> /// <param name="ImageURL">The Product Image URL</param> /// <param name="Status">The Product Status</param> /// <param name="CategoryFK">The Category FK</param> /// <param name="VatRate">The VatRate</param> /// <param name="SupplierFK">The SupplierFK</param> /// <param name="ReorderLevel">The Reorder Level</param> public void UpdateProduct(string ProductID, string Name, string Description, string ImageURL, bool Status, int CategoryFK, double VatRate, int SupplierFK, int ReorderLevel) { try { ProductsRepository myRepository = new ProductsRepository(); ProductsView myProduct = new ProductsView(); myProduct.Id = Guid.Parse(ProductID); myProduct.Name = Name; myProduct.Description = Description; myProduct.ImageURL = ImageURL; myProduct.Status = Status; myProduct.CategoryFK = CategoryFK; myProduct.VatRate = VatRate; myProduct.SupplierFK = SupplierFK; myProduct.ReorderLevel = ReorderLevel; myRepository.UpdateProduct(myProduct); } catch (Exception Exception) { throw Exception; } }
private static ProductsView CreateProductsView() { ProductsView productsView = new ProductsView(); productsView.Presenter = new ProductsPresenter(productsView); return(productsView); }
public ProductsView Create(ProductsView model, out string message) { ProductsView result = new ProductsView(); message = null; try { var product = Helper.ConvertProductViewToProduct(model); product.CreatedDate = DateTime.Now; product.ModifiedDate = DateTime.Now; entities.Products.Add(product); if (entities.SaveChanges() > 0) { result = GetProductById(product.Id, out message); } else { message = Resources.SYSTEM_ERROR_THE_UPDATING_WEBSITE_CONFI_HAS_BEEN_FINISHED; } } catch (Exception ex) { string subject = "Error " + SiteSetting.SiteName + " at Create at ProductRepo at Model.Repository. "; message = StringHelper.Parameters2ErrorString(ex); MailHelper.SendMail(SiteSetting.EmailAdmin, subject, message); } return(result); }
private void FunctionSwitcher(string SelectedFunctionName) { UserControl usc; switch (SelectedFunctionName) { case "Create": usc = new CreateProductView(); break; case "Update": usc = new UpdateProductView(); usc.DataContext = new ProductViewModel { SelectedProductId = this.SelectedProductId }; break; case "Delete": DeleteProduct(); usc = new ProductsView(); break; case "Category": usc = new CategoryView(); break; default: usc = new ProductsView(); break; } ; Session.Instance.SetNextView(usc); }
private UserControl GetView(NavigateInfo navigationInfo) { switch (navigationInfo.ScreenName) { case "SelectCustomer": var view = new CustomersView(); var viewModel = new CustomersViewModel(ServiceLocator.Current.GetInstance <IWebservice>(), navigationInfo.CurrentCart); view.DataContext = viewModel; return(view); case "ProductSelection": var productsView = new ProductsView(); var productsViewModel = new ProductsViewModel(ServiceLocator.Current.GetInstance <IWebservice>(), navigationInfo.CurrentCart); productsView.DataContext = productsViewModel; return(productsView); case "CartCheckout": var cartView = new CartView(); var cartViewModel = new CartViewModel(ServiceLocator.Current.GetInstance <IWebservice>(), navigationInfo.CurrentCart, navigationInfo.CurrentCustomer); cartView.DataContext = cartViewModel; return(cartView); } return(null); }
public ActionResult DeleteConfirmed(int id) { ViewBag.Exception = null; string msg = null; Products product = (from p in db.Products where p.id == id select p).First(); ProductsView productsView = db.ProductsView.SingleOrDefault(m => m.id == id); db.Products.Remove(product); try { db.SaveChanges(); } catch (Exception e) { if (e.InnerException == null) { msg = e.Message; } else { msg = e.InnerException.InnerException.Message; } ViewBag.Exception = msg; return(View(productsView)); } return(RedirectToAction("Index")); }
private void Login() { Person loggedUser; if (Email == "" || Email == null) { MessageBox.Show("Please enter an email"); return; } if (password == "" || password == null) { MessageBox.Show("Please enter a password"); return; } using (var tables = new RestaurantEntities()) { var users = tables.SpFindUserByEmailPassword(Email, Password).ToList(); if (users.Count == 0) { MessageBox.Show("Nonexistent user"); return; } loggedUser = users[0]; } Application.Current.Windows[Application.Current.Windows.Count - 1].Close(); ProductsView view = new ProductsView(); view.DataContext = new ProductsViewModel(loggedUser); view.Show(); }
//[Authorize(Roles = "admin,user")] public async Task <IActionResult> Products(int CategoryId, string Type, string Size, List <Color> Color, List <Subcategory> Subcategory, List <Style> Style) { List <product> products = await db.product.Where(x => x.CategoryId == CategoryId).ToListAsync(); Category category = await db.Category.FirstOrDefaultAsync(n => n.Id == CategoryId); ProductsView model = new ProductsView { Products = products, CategoryName = category.Name }; //if (Type!=null) //{ // products = products.Where(x => x.Type == Type); //} //if (Size != null) //{ // products = products.Where(x => x.Size == Size); //} //if (Color != null) //{ // products = products.Where(x => x.ProductColors.); //} //if (Subcategory != null) //{ // products = products.Where(x => x.Subcategories == Subcategory); //} //if (Style != null) //{ // products = products.Where(x => x.Styles == Style); //} return(View(model)); }
public MainMenuViewModel() { Menu = new ObservableCollection <ItemMenu>(); var product = new ItemMenu() { Name = "Продукт", Open = new Command((() => { var view = new ProductsView(); CurrentPage = view; })) }; var unit = new ItemMenu() { Name = "Единицы измерения", Open = new Command((() => { var view = new UnitsView(); CurrentPage = view; })) }; var recipe = new ItemMenu() { Name = "Рецепты", Open = new Command((() => { var view = new RecipeView(); CurrentPage = view; })) }; var provider = new ItemMenu() { Name = "Поставщики", Open = new Command((() => { var view = new ProductsView(); CurrentPage = view; })) }; var location = new ItemMenu() { Name = "Локации", Open = new Command((() => { var view = new LocationView(); CurrentPage = view; })) }; Menu.Add(product); Menu.Add(unit); Menu.Add(location); Menu.Add(recipe); Menu.Add(provider); }
public ActionResult Search(string s_str) { if (s_str != "") { s_str = s_str.Trim().ToLower(); var ps = ent.Products.ToList(); List <Product> res = new List <Product>(); foreach (var i in ps) { if (i.Pname.Contains(s_str) || i.Pname == s_str || i.Pdescription.Contains(s_str) || i.Pdescription == s_str) { res.Add(i); } } if (res.Count >= 1) { List <Model> model_temp = new List <Model>(); List <P_photo> photos_temp = new List <P_photo>(); List <Brand> brand_t = new List <Brand>(); foreach (var p in res) { var temp = ent.Models.FirstOrDefault(x => x.Id == p.M_id); if (temp != null) { model_temp.Add(temp); } var temp1 = ent.P_photo.FirstOrDefault(x => x.P_id == p.Id); if (temp1 != null) { photos_temp.Add(temp1); } var temp2 = ent.Brands.FirstOrDefault(x => x.Id == p.Id); if (temp2 != null) { brand_t.Add(temp2); } } ProductsView products = new ProductsView { Products = res, Product_b = brand_t, Product_m = model_temp, P_Photos = photos_temp, }; return(PartialView("_Products", products)); } else { return(Content("Such product doesn't exist !")); } } else { return(Content("You entered an empty string, please try again with a string...")); } }
[HttpPost] //設定此Action只接受頁面POST資料傳入 public ActionResult Index(ProductsView Data) { Data.Paging = new ForPaging(Data.intPage); Data.DataList = productsService.GetDataList(Data.Paging, Data); //將頁面資料傳入View中 return(View(Data)); }
public ActionResult ProductCreate() { ProductsView model = new ProductsView(); ViewBag.Title = Resources.LABEL_CREATE_PRODUCT; ViewBag.Action = "ProductCreate"; return(View("ProductEdit", model)); }
// GET: Products public ActionResult Index(int Page = 1) { ProductsView Data = new ProductsView(); Data.Paging = new ForPaging(Page); Data.DataList = productsService.GetAllDataList(Data.Paging); return(View(Data)); }
private static MainView CreateMainView() { ProductsView productsView = CreateProductsView(); GroupsView groupsView = CreateGroupsView(); ReceiptView receiptView = CreateReceiptView(); MainView mainView = new MainView(groupsView, productsView, receiptView); mainView.Presenter = new MainPresenter(mainView); return(mainView); }
public IActionResult GetPaging(int page) { ProductsView productoView = repo.GetPaginado(page); if (productoView == null) { return(HttpNotFound()); } return(new ObjectResult(productoView)); }
// GET: Admin/Product/Create public ActionResult Create() { var model = new ProductsView(); model.Status = nameof(StatusEntity.Active); model.ProductDetail = new List <ProductDetailModel>() { new ProductDetailModel() }; return(View(model)); }
// GET: Product public ActionResult Index() { ProductsView PV = new ProductsView { Products = PF.GetAllRealtion(), Categories = CF.GetAll(), json = JObject.Parse(FT.LoadFile(Request.PhysicalApplicationPath + "/ServerData/Pages.json")) }; return(View(PV)); }
private void MenuButtonProducts_Click(object sender, EventArgs e) { //Switches to the product screen ProductsView productsView = new ProductsView(WorkingArea); MenuButtonDelete.Show(); MenuButtonDelete.Click += productsView.SimulateDeleteKey; //productsView SwitchView(productsView); MenuButtonProducts.BackColor = Color.DarkSlateBlue; MenuPanel.Size = new Size(WorkingArea.Width, 100); }
protected void ProductsView_DataBound(object sender, EventArgs e) { System.Web.UI.WebControls.Image image = (System.Web.UI.WebControls.Image)ProductsView.FindControl("image"); if (image == null) { return; } if (!File.Exists(MapPath(image.ImageUrl))) { image.ImageUrl = "../images/noimage.jpg"; } }
public void Execute() { PresentProductsRequest request = new PresentProductsRequest(); List <Product> products = requestBus.Send <PresentProductsRequest, List <Product> >(request); ProductsViewModel viewModel = new ProductsViewModel { Products = products }; ProductsView view = new ProductsView(viewModel); view.Display(); }
public ActionResult ProductCreate(ProductsView model, string saveclose, string savenew) { ProductsView remodel = new ProductsView(); var actionStatus = new ActionResultHelper(); actionStatus.ActionStatus = ResultSubmit.failed; string message = ""; bool IsValid = true; if (ModelState.IsValid) { model.ModifiedBy = CurrentUser.ID; model.Language = currentCulture.ToString(); model.CreatedBy = CurrentUser.ID; remodel = _proRepo.Create(model, out message); if (remodel != null && String.IsNullOrWhiteSpace(message)) { actionStatus.ErrorReason = String.Format(SiteResource.HTML_ALERT_SUCCESS, Resources.MSG_THE_PRODUCT_HAS_CREATED_SUCCESSFULL); actionStatus.ActionStatus = ResultSubmit.success; Session["ACTION_STATUS"] = actionStatus; if (!String.IsNullOrEmpty(saveclose)) { return(RedirectToAction("Products")); } else if (!String.IsNullOrWhiteSpace(savenew)) { return(RedirectToAction("ProductCreate")); } else { return(RedirectToAction("ProductEdit", new { Id = remodel.ID })); } } else { IsValid = false; actionStatus.ErrorStrings.Add(Resources.MSG_THE_PRODUCT_HAS_CREATED_SUCCESSFULL); goto actionError; } } actionError: if (!IsValid) { actionStatus.ErrorReason = String.Format(SiteResource.HTML_ALERT_ERROR, actionStatus.ShowErrorStrings()); Session["ACTION_STATUS"] = actionStatus; } ViewBag.Title = Resources.LABEL_CREATE_PRODUCT; ViewBag.Action = "ProductCreate"; return(View("ProductEdit", model)); }
void ReleaseDesignerOutlets() { if (ProductsView != null) { ProductsView.Dispose(); ProductsView = null; } if (TableView != null) { TableView.Dispose(); TableView = null; } }
public IHttpActionResult UpdateProduct([FromBody] ProductsView productView) { var product = mapper.Map <ProductsDTM>(productView); try { service.UpdateAsync(product); return(Ok("Updated product:" + product)); } catch { return(BadRequest("Can`t update products")); } }
// GET: ProductsViews/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ProductsView productsView = db.ProductsView.SingleOrDefault(m => m.id == id); if (productsView == null) { return(HttpNotFound()); } return(View(productsView)); }
public void Apply(OrderPlaced e) { var productView = new ProductsView(); var product = productView.GetById(e.ProductId); var dto = new OrderDto { Id = e.Id, Quantity = e.Quantity, ProductName = product.Description, Version = e.Version, IsPaidFor = false }; repository.Insert(dto); }
// GET: ProductsViews/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ProductsView productsView = db.ProductsView.SingleOrDefault(m => m.id == id); if (productsView == null) { return(HttpNotFound()); } ViewBag.producer_name = new SelectList(db.Producers, "name", "name"); return(View(productsView)); }
public static Product Create(ProductsView viewProduct) { var product = new Product { ProductName = viewProduct.ProductName, Price = viewProduct.Price, BasicPrice = viewProduct.BasicPrice, BarcodeNumber = viewProduct.BarcodeNumber, CurrencyId = viewProduct.CurrencyId, Currency = viewProduct.Currency, ProductCategoryId = viewProduct.ProductCategoryId }; return(product); }
public ActionResult Edit([Bind(Include = "id,name,producer_name,price,alcohol_percentage,volume,RowVersion")] ProductsView productsView) { ViewBag.Exception = null; string msg = ""; if (ModelState.IsValid) { var entity = db.Products.Single(p => p.id == productsView.id); if (entity.RowVersion != productsView.RowVersion) { TempData["Exception"] = "Entity was modified by another user. Check values and perform edit action again."; return(RedirectToAction("Edit")); } entity.RowVersion++; entity.name = productsView.name; entity.producer_id = (from p in db.Producers where p.name == productsView.producer_name select p).Single().id; entity.price = productsView.price; entity.alcohol_percentage = productsView.alcohol_percentage; entity.volume = productsView.volume; db.Entry(entity).State = EntityState.Modified; try { db.SaveChanges(); } catch (Exception e) { if (e.InnerException == null) { msg = e.Message; } else { msg = e.InnerException.InnerException.Message; } ViewBag.Exception = msg; ViewBag.producer_name = new SelectList(db.Producers, "name", "name"); return(View(productsView)); } return(RedirectToAction("Index")); } ViewBag.producer_name = new SelectList(db.Producers, "name", "name"); return(View(productsView)); }
private void CreateSampleWorker(object[] args) { SampleUtilities.RegisterToolboxWidget("Products Widget", typeof(ProductsView), "Samples"); SampleUtilities.RegisterTheme(SamplesThemeName, SamplesThemePath); SampleUtilities.RegisterTemplate(new Guid(SamplesTemplateId), SamplesTemplateName, SamplesTemplateName, SamplesTemplatePath, SamplesThemeName); var result = SampleUtilities.CreatePage(new Guid(ProductsPageId), ProductsPageName, true); if (result) { SampleUtilities.SetTemplateToPage(new Guid(ProductsPageId), new Guid(SamplesTemplateId)); ProductsView productsView = new ProductsView(); SampleUtilities.AddControlToPage(new Guid(ProductsPageId), productsView, "Content", "Products Widget"); } }
private void CreateShopPage() { var hasCreatedPage = SampleUtilities.CreateLocalizedPage(new Guid(SampleConstants.ShopBasePageId), "TIU Shop", false, true, "en"); if (hasCreatedPage) { SampleUtilities.SetTemplateToLocalizedPage(new Guid(SampleConstants.ShopBasePageId), new Guid(SampleConstants.EducationTemplateId), "en"); // Add page title ContentBlockBase pageTitle = new ContentBlockBase(); pageTitle.Html = "<h1>University shop</h1>"; SampleUtilities.AddControlToLocalizedPage(new Guid(SampleConstants.ShopBasePageId), pageTitle, "content", "Title", "en"); // Add layout control var mainLayoutControl = new LayoutControl(); var mainLayoutColumns = new List<ColumnDetails>(); var mainLayoutColumn1 = new ColumnDetails() { ColumnSpaces = new ColumnSpaces(0, 15, 0, 0), PlaceholderId = "Left", ColumnWidthPercentage = 75 }; mainLayoutColumns.Add(mainLayoutColumn1); var mainLayoutColumn2 = new ColumnDetails() { ColumnSpaces = new ColumnSpaces(0, 0, 0, 15), PlaceholderId = "Right", ColumnWidthPercentage = 25 }; mainLayoutColumns.Add(mainLayoutColumn2); mainLayoutControl.Layout = SampleUtilities.GenerateLayoutTemplate(mainLayoutColumns, string.Empty); mainLayoutControl.ID = "Main"; SampleUtilities.AddControlToLocalizedPage(new Guid(SampleConstants.ShopBasePageId), mainLayoutControl, "content", "75% + 25% (custom)", "en"); ProductsView productsList = new ProductsView(); SampleUtilities.AddControlToLocalizedPage(new Guid(SampleConstants.ShopBasePageId), productsList, "Main_Left", "Product list", "en"); ShoppingCartSummary shoppingCartSummary = new ShoppingCartSummary(); shoppingCartSummary.CheckoutData = @"{""Id"":""" + SampleConstants.ShopCheckoutPageId + @""",""Title"":""Checkout""}"; shoppingCartSummary.CheckoutUrl = "~/tiu-shop/checkout"; shoppingCartSummary.ContinueShoppingData = @"{""Id"":""" + SampleConstants.ShopBasePageId + @""",""Title"":""TIU Shop""}"; shoppingCartSummary.ContinueShoppingUrl = "~/tiu-shop"; shoppingCartSummary.ShoppingCartData = @"{""Id"":""" + SampleConstants.ShopShoppingCartPageId + @""",""Title"":""Shopping cart""}"; shoppingCartSummary.ShoppingCartUrl = "~/tiu-shop/shopping-cart"; // set the Simple list template! shoppingCartSummary.TemplateKey = this.GetShoppingCartSummaryTemplateKey(); SampleUtilities.AddControlToLocalizedPage(new Guid(SampleConstants.ShopBasePageId), shoppingCartSummary, "Main_Right", "Shopping cart summary", "en"); } }