public async Task <IActionResult> Discount(ProductDiscountViewModel model) { if (!ModelState.IsValid) { return(RedirectToAction("Details", new { model.Id })); } Product product = await _store.GetByIdAsync(model.Id); if (product == null) { return(NotFound()); } var operation = ProductOperations.GiveDiscount(model.Discount); if (await _authz.AuthorizeAsync(User, product, operation)) { product.Price -= model.Discount; await _store.UpdateAsync(product); return(RedirectToAction("Index")); } return(new ChallengeResult()); }
protected void RadGrid1_OnInsertCommand(object sender, GridCommandEventArgs e) { try { var editableItem = ((GridEditableItem)e.Item); var product = new ProductDto(); editableItem.UpdateValues(product); if (product.WeightedItem == null) { product.WeightedItem = false; } var result = ProductOperations.Create(product); if (result.IsSuccess) { this.ShowToast(ToastTypeEnum.Success, "Successfully created Item", "Success"); return; } ShowErrorMessage(result.ErrorMessage); } catch (Exception ex) { ErrorHandler.LogException(ex); ShowErrorMessage("There was a problem Updating the item."); } }
static void Main(string[] args) { Product item1 = new Product(), item2 = new Product(), item3 = new Product(); ProductOperations min = Conveyor.Size; min += Conveyor.Cut; min += Conveyor.Slice; min += Conveyor.Drill; ProductOperations dye = Conveyor.Size; dye += Conveyor.Cut; dye += Conveyor.Slice; dye += Conveyor.Dye; ProductOperations full = Conveyor.Size; full += Conveyor.Cut; full += Conveyor.Sharpen; full += Conveyor.Slice; full += Conveyor.Drill; full += Conveyor.Dye; full += Conveyor.Test; full += Conveyor.Pack; min(item1); dye(item2); full(item3); Conveyor.Data(item1); Conveyor.Data(item2); Conveyor.Data(item3); Console.Read(); }
//ConnectedOrder connectedOrders; public OrderViewModel() { orderOperationsObj = new OrderOperations(); productOperationObj = new ProductOperations(); orderDetailListObj = new OrderDetailsList(); currentOrder = new Order(); currentOrder.OrderCreate = DateTime.Today; currentOrder.DispatchDate = DateTime.Today; Console.WriteLine($"Current Order ID : {currentOrder.Id}"); listReadingOrder = new List <Order>(); LoadCustomersList(); LoadProductsList(); selectedCustomer = new Customer(); selectedProduct = ListOfProducts[0]; LoadCurrentOrderDetalList(); addProductToList = new OrderCommands(AddProductToDetailList); //addOrderToList = new OrderCommands(AddToOrder); addOrderToList = new OrderCommands(AddOrderToListMethod); LoadOrdersList(); productSizesTable = new int[14]; readingOrder = new Order(); updateOrderStatus = new OrderCommands(updateOrderStatusMethod); //connectedOrders = new ConnectedOrder(OrdersList, CurrentOrderDetailList); //connectedOrders.sortedOrderInformation(OrdersList, CurrentOrderDetailList); //connectedOrders = new ConnectedOrder(OrdersList, CurrentOrderDetailList); //connectedOrderCol = connectedOrders.sortedOrderInformation(OrdersList, CurrentOrderDetailList); ListReadingOrderMethod(); //Console.WriteLine($"Lista : {ListReadingOrder[0].OrderDetailsLists[0]}"); }
static void Main(string[] args) { Console.WriteLine("Product-Catalog"); Console.WriteLine("1.PRODUCT"); Console.WriteLine("2.CATEGORY"); Console.WriteLine("3.EXIT-APP"); char ch = Convert.ToChar(Console.ReadLine()); switch (ch) { case '1': ProductOperations.ProductOperationMenu(); break; case '2': CategoryOperations.CategoryOperationMenu(); break; case '3': break; default: Console.WriteLine("Please Enter Valid Options"); break; } }
public async Task <IHttpActionResult> Discount(int id, decimal discount) { if (discount < 1 || discount > 100) { return(BadRequest(ModelState)); } Product product = await _store.GetByIdAsync(id); if (product == null) { return(NotFound()); } var operation = ProductOperations.GiveDiscount(discount); if (await _authz.AuthorizeAsync((ClaimsPrincipal)User, product, operation)) { product.Price -= discount; await _store.UpdateAsync(product); return(Ok(product)); } return(StatusCode(HttpStatusCode.Forbidden)); }
public void Productos() { ProductOperations po = new ProductOperations(); string me = ""; GridView1.DataSource = po.BuscarProductos(ref me); GridView1.DataBind(); }
public async Task SerializeProducts() { var products = await ProductOperations.GetProductsByCategory(3, false); var json = ProductOperations.Serialize(products); Assert.IsNotNull(json); File.WriteAllText("SerializedProducts.json", json); }
private void SetDataSources() { var allProducts = ProductOperations.GetAll()?.ItemList ?? new List <ProductDto>(); var branchProducts = ddlBranches.SelectedValue == "0" ? new List <ProductDto>() : ProductOperations.GetAllByStoreId(int.Parse(ddlBranches.SelectedValue)); RadListBoxSource.DataSource = branchProducts.Count > 0 ? allProducts.Where(p => !branchProducts.Contains(p)) : allProducts; RadListBoxSource.DataBind(); RadListBoxDestination.DataSource = branchProducts; RadListBoxDestination.DataBind(); }
private void Product_Load(object sender, EventArgs e) { ProductOperations bl = new ProductOperations(); IList <Product> pro = bl.RetrieveProductList(); foreach (Product p in pro) { dataGridView1.Rows.Add(p.ID, p.Title, p.Description, p.Color, p.Size, p.Price, p.Stock); } }
public override void BeforeEach() { base.BeforeEach(); _gameRepository = Container.Resolve <IGameRepository>(); _productOperations = Container.Resolve <ProductOperations>(); PlayerTestHelper = Container.Resolve <PlayerTestHelper>(); GamesTestHelper = Container.Resolve <GamesTestHelper>(); BrandTestHelper = Container.Resolve <BrandTestHelper>(); }
public bool UpdateProduct(Product pobj) { bool result = false; if (Validate(pobj)) { ProductOperations po = new ProductOperations(); result = po.UpdateProduct(pobj); } return(result); }
public AdminApi(IOrderRepository orderRepository, IUserRepository userRepository, IProductRepository productRepository, ProductOperations productOperations, OrderOperations orderOperations, UserOperations userOperations) { this.orderRepository = orderRepository; this.userRepository = userRepository; this.productRepository = productRepository; this.productOperations = productOperations; this.orderOperations = orderOperations; this.userOperations = userOperations; }
public ProductViewModel() { productOperationObj = new ProductOperations(); LoadData(); CurrentProduct = new Product(); saveProductCommand = new ProductCommands(Save); searchProductCommand = new ProductCommands(Search); updateProductCommand = new ProductCommands(Update); deleteProductCommand = new ProductCommands(Delete); updateTempProductCommand = new ProductCommands(UpdateTemp); openFileImageProductCommand = new ProductCommands(OpenFileDialog); }
public void DisplayProductCatalog() { ProductOperations productOperations = new ProductOperations(ProductFilePath); bool ProductStop = false; while (ProductStop != true) { Console.WriteLine("1. Add a Product"); Console.WriteLine("2. List all Products"); Console.WriteLine("3. Delete a Product(Enter Short Code or ID to delete)"); Console.WriteLine("4. Search a Product"); Console.WriteLine("5. Exit"); int i = Convert.ToInt32(Console.ReadLine()); switch (i) { case 1: Console.WriteLine("Enter a Product Details"); productOperations.AddProduct(); break; case 2: Console.WriteLine("List all Product"); productOperations.DisplayProduct(); break; case 3: Console.WriteLine("Delete a Product"); productOperations.DeleteProduct(); break; case 4: Console.WriteLine("Search a Product"); productOperations.findProduct(); break; case 5: ProductStop = true; Console.WriteLine("Exiting"); Console.Clear(); // this.DisplayCatalog(); break; default: Console.WriteLine("Invalid Operation"); break; } } }
public ActionResult Edit(ProductModel editModel) { try { var actionModel = new ProductOperations(); actionModel.Edit(editModel); return(RedirectToAction("Index")); } catch { return(View(new ProductModel())); } }
public ActionResult Create(ProductModel vm) { try { var actionModel = new ProductOperations(); actionModel.Create(vm); return(RedirectToAction("Index")); } catch { return(View(new ProductModel())); } }
private void btnProduct_Click(object sender, EventArgs e) { var productForm = new FormProduct(); var productRepository = new DataAccessProduct(); var productPresenter = new ProductOperations(productForm, productRepository); productForm.Show(); if (this.Product != null) { this.Product(); } }
public void TestWithquantityMoreThan1_Scenario3() { var consoleMock = new Mock <IConsoleMethods>(); consoleMock.Setup(c => c.WriteLine(It.IsAny <string>())); ProductOperations productOperations = new ProductOperations(consoleMock.Object); productOperations.registerProductOffers(); float totalCost = productOperations.calculateTotalPrice(3, 5, 1, 1); Assert.AreEqual(280, totalCost); }
public void Not_Senior_Sales_Department_User_Allowed_To_Discount_Standard_Product_If_External_Service_Allows() { var requirement = ProductOperations.GiveDiscount(10); var user = CreateSalesDepartmentPrincipal(); var product = new Product { Id = 1, ProductType = ProductType.Standard }; var context = new AuthorizationContext(new[] { requirement }, user, product); _isDiscountAllowedResult = true; _handler.Handle(context); context.HasSucceeded.Should().BeTrue(); }
//Method to add new product public bool AddProduct(Product pobj) { bool result = false; //checking if the product object is valid if (Validate(pobj)) { //Creating DAL class object ProductOperations po = new ProductOperations(); //Invoking its AddProduct method return(po.AddProduct(pobj)); } return(result); }
public void Senior_Sales_Department_User_NOT_Allowed_To_Discount_Special_Product_If_External_Service_NOT_Allows() { var requirement = ProductOperations.GiveDiscount(10); var user = CreateSalesDepartmentPrincipal(); user.Identities.First().AddClaim(new Claim("status", "senior")); var product = new Product { Id = 1, ProductType = ProductType.Special }; var context = new AuthorizationContext(new[] { requirement }, user, product); _isDiscountAllowedResult = false; _handler.Handle(context); context.HasSucceeded.Should().BeFalse(); }
private void Delete_Click(object sender, EventArgs e) { Product product = new Product(); product.ID = Convert.ToInt32(textID.Text); product.Title = textBox1.Text; product.Description = textBox2.Text; product.Color = textBox3.Text; // product.Size = Convert.ToDouble(textBox4.Text); // product.Price = Convert.ToDouble(textBox5.Text); //product.Stock = Convert.ToInt32(textBox6.Text); ProductOperations bl = new ProductOperations(); bl.DeleteProduct(product); MessageBox.Show("Operation succesful"); }
protected void Button1_Click(object sender, EventArgs e) { int Tamanio = fupImgP.PostedFile.ContentLength; byte[] imagenOriginal = new byte[Tamanio]; fupImgP.PostedFile.InputStream.Read(imagenOriginal, 0, Tamanio); Bitmap imagenOriginalBinary = new Bitmap(fupImgP.PostedFile.InputStream); string imagenUrl64 = "data:image/jpg;base64," + Convert.ToBase64String(imagenOriginal); imgPreview.ImageUrl = imagenUrl64; ProductOperations po = new ProductOperations(); string j = ""; po.InsertMaterial(txtFolio.Text, txtName.Text, txtDesc.Text, Convert.ToSingle(txtPre.Text), imagenOriginal.ToString(), Convert.ToSingle(txtLarg.Text), Convert.ToSingle(txtAncho.Text), Convert.ToSingle(txtAlto.Text), misids[dplMaterial.SelectedIndex], ref j); }
private void btnSave_Click(object sender, EventArgs e) { try { if (Validate()) { Product product = new Product() { CGST = Convert.ToDouble(txtcgst.Text), IGST = Convert.ToDouble(txtIGST.Text), Name = txtname.Text, Rate = Convert.ToDouble(txtrate.Text), SGST = Convert.ToDouble(txtSGST.Text) }; // Material material = new Material(); //material.Name = txtmaterialtype.Text; product.material = txtmaterialtype.Text; product.ProductId = ProductId; bool status = ProductOperations.SaveProduct(product); if (status) { MessageBox.Show("Product Saved", "OK"); } else { MessageBox.Show("Product is not saved", "Warning"); } if (ProductId == -1) { Clear(); } else { this.Close(); } } else { MessageBox.Show("Please enter all the fields", "Validation"); } } catch (Exception ex) { BusinessModel.Log.Logger(ex); } }
private void btnAddProduct_Click_1(object sender, EventArgs e) { try { Product product = new Product(); product.ID = Convert.ToInt32(textID.Text); product.Title = textBox1.Text; product.Description = textBox2.Text; product.Color = textBox3.Text; product.Size = Convert.ToDouble(textBox4.Text); product.Price = Convert.ToDouble(textBox5.Text); product.Stock = Convert.ToInt32(textBox6.Text); ProductOperations bl = new ProductOperations(); bl.AddProduct(product); MessageBox.Show("Operation succesful"); } catch (Exception) { MessageBox.Show("Datele au fost introduse gresit!"); } }
protected void RadListBoxSource_OnTransferred(object sender, RadListBoxTransferredEventArgs e) { if (ddlBranches.SelectedValue == "0") { ShowErrorMessage("Please select a branch from the dropdown."); return; } var itemIds = new List <int>(); foreach (var radListBoxItem in e.Items) { itemIds.Add(int.Parse(radListBoxItem.Value)); } foreach (var itemId in itemIds) { var result = ProductOperations.AssignAProductToAStore(int.Parse(ddlBranches.SelectedValue), itemId); if (!result.IsSuccess) { ShowErrorMessage("A problem occured while assigning one or more of the products."); } } }
private void btnAdd_Click(object sender, EventArgs e) { //add order Order order = new Order(); OrdersOperations bl = new OrdersOperations(); order.ID = Convert.ToInt32(textBox1.Text); order.IdCustomer = Convert.ToInt32(textBox2.Text); order.IdEmployee = Convert.ToInt32(textBox3.Text); order.ShippindAddress = textBox4.Text; order.IdentificationNr = Convert.ToInt32(textBox5.Text); order.DeliveryDate = date.Value; order.Status = textBox7.Text; bl.AddOrder(order); //add ativity employee Activity activity = new Activity(); ActivityOperations blll = new ActivityOperations(); activity.IdEmployee = Convert.ToInt32(textBox3.Text); activity.AddOp = 1; activity.UpdateOp = 0; activity.Viewproduct = 0; activity.DeliveryDate = date.Value.ToString("yyyy-MM-dd"); // string d1 = date1.Value.ToString("yyyy-MM-dd"); blll.AddActivity(activity); //total order double sum = 0; OrderProduct po = new OrderProduct(); // Product prod = new Product(); po.IdOrder = Convert.ToInt32(textBox1.Text); OrderProductOperations y = new OrderProductOperations(); IList <OrderProduct> listIdProdus = y.RetrieveOrderProductList(po.IdOrder); ProductOperations op1 = new ProductOperations(); foreach (OrderProduct i in listIdProdus) { IList <Product> listP = op1.RetrieveProductOrderList(i.IdProduct); foreach (Product j in listP) { sum += j.Price; } } Console.WriteLine(sum); //suma = Convert.ToString(sum); textBox8.Text = sum.ToString(); MessageBox.Show("Operation succesful"); }
private void btnAddProduct_Click(object sender, EventArgs e) { OrderProduct op = new OrderProduct(); OrderProductOperations bl = new OrderProductOperations(); op.IdOrder = Convert.ToInt32(textBox1.Text); op.IdProduct = Convert.ToInt32(textBox6.Text); // op.Stock = Convert.ToInt32(textBox3.Text); bl.AddProductOrder(op); //- stock Product p = new Product(); p.ID = Convert.ToInt32(textBox6.Text); ProductOperations x = new ProductOperations(); IList <Product> pro = x.RetrieveProductOrderList(p.ID); foreach (Product pp in pro) { pp.Stock = pp.Stock - 1; x.UpdateProduct(p.ID, pp.Stock); } ///test /// //total order double sum = 0; OrderProduct po = new OrderProduct(); // Product prod = new Product(); po.IdOrder = Convert.ToInt32(textBox1.Text); OrderProductOperations y = new OrderProductOperations(); IList <OrderProduct> listIdProdus = y.RetrieveOrderProductList(po.IdOrder); ProductOperations op1 = new ProductOperations(); foreach (OrderProduct i in listIdProdus) { IList <Product> listP = op1.RetrieveProductOrderList(i.IdProduct); foreach (Product j in listP) { sum += j.Price; } } Console.WriteLine(sum); //suma = Convert.ToString(sum); textBox8.Text = sum.ToString(); }
/// <summary> /// Initializes client properties. /// </summary> private void Initialize() { Policy = new PolicyOperations(this); PolicySnippets = new PolicySnippetsOperations(this); Regions = new RegionsOperations(this); Api = new ApiOperations(this); ApiRevisions = new ApiRevisionsOperations(this); ApiRelease = new ApiReleaseOperations(this); ApiOperation = new ApiOperationOperations(this); ApiOperationPolicy = new ApiOperationPolicyOperations(this); ApiProduct = new ApiProductOperations(this); ApiPolicy = new ApiPolicyOperations(this); ApiSchema = new ApiSchemaOperations(this); ApiDiagnostic = new ApiDiagnosticOperations(this); ApiDiagnosticLogger = new ApiDiagnosticLoggerOperations(this); ApiIssue = new ApiIssueOperations(this); ApiIssueComment = new ApiIssueCommentOperations(this); ApiIssueAttachment = new ApiIssueAttachmentOperations(this); AuthorizationServer = new AuthorizationServerOperations(this); Backend = new BackendOperations(this); Certificate = new CertificateOperations(this); ApiManagementOperations = new ApiManagementOperations(this); ApiManagementServiceSkus = new ApiManagementServiceSkusOperations(this); ApiManagementService = new ApiManagementServiceOperations(this); Diagnostic = new DiagnosticOperations(this); DiagnosticLogger = new DiagnosticLoggerOperations(this); EmailTemplate = new EmailTemplateOperations(this); Group = new GroupOperations(this); GroupUser = new GroupUserOperations(this); IdentityProvider = new IdentityProviderOperations(this); Logger = new LoggerOperations(this); Notification = new NotificationOperations(this); NotificationRecipientUser = new NotificationRecipientUserOperations(this); NotificationRecipientEmail = new NotificationRecipientEmailOperations(this); NetworkStatus = new NetworkStatusOperations(this); OpenIdConnectProvider = new OpenIdConnectProviderOperations(this); SignInSettings = new SignInSettingsOperations(this); SignUpSettings = new SignUpSettingsOperations(this); DelegationSettings = new DelegationSettingsOperations(this); Product = new ProductOperations(this); ProductApi = new ProductApiOperations(this); ProductGroup = new ProductGroupOperations(this); ProductSubscriptions = new ProductSubscriptionsOperations(this); ProductPolicy = new ProductPolicyOperations(this); Property = new PropertyOperations(this); QuotaByCounterKeys = new QuotaByCounterKeysOperations(this); QuotaByPeriodKeys = new QuotaByPeriodKeysOperations(this); Reports = new ReportsOperations(this); Subscription = new SubscriptionOperations(this); TagResource = new TagResourceOperations(this); Tag = new TagOperations(this); TagDescription = new TagDescriptionOperations(this); Operation = new OperationOperations(this); TenantAccess = new TenantAccessOperations(this); TenantAccessGit = new TenantAccessGitOperations(this); TenantConfiguration = new TenantConfigurationOperations(this); User = new UserOperations(this); UserGroup = new UserGroupOperations(this); UserSubscription = new UserSubscriptionOperations(this); UserIdentities = new UserIdentitiesOperations(this); ApiVersionSet = new ApiVersionSetOperations(this); ApiExport = new ApiExportOperations(this); BaseUri = new System.Uri("https://management.azure.com"); ApiVersion = "2018-01-01"; AcceptLanguage = "en-US"; LongRunningOperationRetryTimeout = 30; GenerateClientRequestId = true; SerializationSettings = new JsonSerializerSettings { Formatting = Newtonsoft.Json.Formatting.Indented, DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), Converters = new List <JsonConverter> { new Iso8601TimeSpanConverter() } }; SerializationSettings.Converters.Add(new TransformationJsonConverter()); DeserializationSettings = new JsonSerializerSettings { DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), Converters = new List <JsonConverter> { new Iso8601TimeSpanConverter() } }; CustomInitialize(); DeserializationSettings.Converters.Add(new TransformationJsonConverter()); DeserializationSettings.Converters.Add(new CloudErrorJsonConverter()); }