public ClientProductArr Filter(int id, Client client, Product product) { ClientProductArr clientProductArr = new ClientProductArr(); for (int i = 0; i < this.Count; i++) { //הצבת המוצר הנוכחי במשתנה עזר - מוצר ClientProduct clientProduct = (this[i] as ClientProduct); if ( //סינון לפי מזהה המוצר (id <= 0 || clientProduct.Id == id) //סינון לפי החברה && (client == null || client.ID == -1 || clientProduct.Client.ID == client.ID) //סינון לפי קטגוריה && (product == null || product.ID == -1 || clientProduct.Product.ID == product.ID) ) { //המוצר ענה לדרישות החיפוש - הוספה שלו לאוסף המוחזר clientProductArr.Add(clientProduct); if (id > 0) { break; } } } return(clientProductArr); }
public IActionResult Create([FromBody] MultiAssistDto payload) { try { int cpId; ClientProduct clientProduct = new ClientProduct { ClientId = payload.ClientId, ProductId = 2, //MULTI-ASSIST ID Status = 0, CreatedAt = DateTime.Now }; cpId = _clientProductService.Create(clientProduct); if (cpId > 0) { payload.MultiAssist.ClientProductId = cpId; _service.Create(payload.MultiAssist); payload.MultiAssist.ClientProduct = null; } else { return(BadRequest()); } return(Ok(payload)); } catch (System.Exception ex) { return(DefaultError(ex)); } }
public IActionResult Post([FromBody] ClientProduct sale) { try { if (sale is null) { _logger.LogWarning($"Sale is null reference"); return(BadRequest("Client or product is null")); } if (!ModelState.IsValid) { _logger.LogError($"Validation error"); return(BadRequest("Data is incorrect")); } else { _dataRepository.Add(sale); _logger.LogInformation($"New sale was created succesfully"); return(StatusCode(StatusCodes.Status201Created)); } } catch (Exception ex) { _logger.LogInformation($"{ex.Message}", ex); return(StatusCode(500, "A problem happened while handing your request")); } }
public ActionResult Create(ProductManageViewModel productManageViewModel) { if (ModelState.IsValid) { foreach (var cli in productManageViewModel.ClientProducts) { clientProduct = new ClientProduct { UsersId = cli.UsersId, ProductId = cli.ProductId }; db.ClientProducts.Add(clientProduct); db.SaveChanges(); } foreach (var sup in productManageViewModel.SupportProducts) { supportProduct = new SupportProduct { UsersId = sup.UsersId, ProductId = sup.ProductId }; db.SupportProducts.Add(supportProduct); db.SaveChanges(); } return(RedirectToAction("Index")); } ViewBag.ProductId = new SelectList(db.Products, "ID", "Name", productManageViewModel.ProductId); ViewBag.SupportId = new SelectList(db.Users.Where(s => s.UserType == "Support"), "ID", "UserName", productManageViewModel.SupportId); ViewBag.ClientId = new SelectList(db.Users.Where(c => c.UserType == "Client"), "ID", "UserName", productManageViewModel.ClientId); return(View(productManageViewModel)); }
public async Task AddProductPostProcess(int productId) { var product = await _dbContext.Product.FirstOrDefaultAsync(p => p.Id == productId); var result = await _dbContext.ClientСriteria .Include(c => c.Client) .Include(c => c.Criteria) .ToArrayAsync(); var clientСriterias = result.GroupBy(c => c.Client).ToDictionary(g => g.Key, g => g.ToList()); foreach (var client in clientСriterias) { var interpreter = new Interpreter(); foreach (var clCriteria in client.Value) { interpreter.SetVariable(clCriteria.Criteria.Name, clCriteria.GetValue()); } if (product != null && interpreter.Eval <bool>(product.Expression)) { if (product != null) { var clientProduct = new ClientProduct { Client = client.Key, Product = product, }; await _dbContext.ClientProduct.AddAsync(clientProduct); } } } await _dbContext.SaveChangesAsync(); }
public IActionResult CreateView() { ViewData["ClientId"] = new SelectList(_work.Client.GetAll(), "Id", "Name"); ViewData["ProductId"] = new SelectList(_work.Products.GetAll(), "Id", "Name"); ClientProduct clientproject = new ClientProduct(); return(PartialView("_Create", clientproject)); }
public int Create(ClientProduct payload) { try { this._context.ClientProduct.Add(payload); this._context.SaveChanges(); return(payload.Id); } catch (System.Exception ex) { return(-1); } }
public ClientProduct GetModel() { ClientProduct a = new ClientProduct(); a.Id = this.Id; a.ClientId = this.ClientId; a.ProductName = this.ProductName; return(a); }
private ClientProduct FormtoClientProduct() { ClientProduct clientProduct = new ClientProduct(); clientProduct.Id = Convert.ToInt32(labelClientProductID.Text); clientProduct.Client = GetClientFromForm(); clientProduct.Product = GetProductFromForm(); clientProduct.DateIntrestedSince = DateTime.Now; return(clientProduct); }
public IActionResult Edit(ClientProduct clientProject) { if (ModelState.IsValid) { _work.ClientProducts.Update(clientProject); _work.Complete(); return(PartialView("_Edit", clientProject)); } ViewData["ClientId"] = new SelectList(_work.Client.GetAll(), "Id", "Name"); ViewData["ProductId"] = new SelectList(_work.Products.GetAll(), "Id", "Name"); return(PartialView("_Edit", clientProject)); }
static void Main(string[] args) { string endpoint = "http://localhost:58125/api/v1/products"; Console.WriteLine("Please wait until website is fully loaded..."); Console.WriteLine("Then hit ENTER to start..."); Console.ReadLine(); // Get products with Participant information var products = Get <List <ClientProduct> >(endpoint + "?expand=Participant").Result; Console.WriteLine("Read " + products.Count + " products with Participant details"); var product = Get <ClientProduct>(endpoint + "/4").Result; Console.WriteLine("Read single product with title: " + product.Title); // Insert new product product = new ClientProduct { Title = "Test title", Description = "Great art work", Price = 100, Image = "art.jpg", AvgStars = 0, QuantitySold = 0, Participant = new ClientParticipant { Href = product.Href } }; product = Post <ClientProduct>(endpoint, product).Result; Console.WriteLine("Inserted product with href: " + product.Href); // Update product product.Title = "Another title"; product.Price = 400; product = Put <ClientProduct>(product.Href, product).Result; Console.WriteLine("Changed product with href: " + product.Href); // Delete product product = Delete <ClientProduct>(product.Href).Result; Console.WriteLine("Deleted product with href: " + product.Href); Console.WriteLine(); Console.Write("Hit ENTER to quit..."); Console.ReadKey(); }
private void DoWork(object state) { using (var scope = scopeFactory.CreateScope()) { Random random = new Random(); var _clients = scope.ServiceProvider.GetRequiredService <IDataRepository <Client> >(); var _sales = scope.ServiceProvider.GetRequiredService <IDataRepository <ClientProduct> >(); var _dishes = scope.ServiceProvider.GetRequiredService <IDataRepository <Product> >(); var logger = scope.ServiceProvider.GetRequiredService <ILogger <Producer> >(); var count = Interlocked.Increment(ref executionCount); var firstHungryClient = _clients.GetLast(); if (firstHungryClient == null) { logger.LogInformation($"No hungry clients".ToUpper()); } else { var randomIdOfDish = random.Next(1, _dishes.Count()); logger.LogInformation($"[{firstHungryClient.Id}] {firstHungryClient.Name.ToUpper()}" + $" {firstHungryClient.SecondName.ToUpper()} is hungry." + $"You should give him something to eat or drink! Hurry up!"); var sale = new ClientProduct() { ClientId = firstHungryClient.Id, ProductId = randomIdOfDish }; _sales.Add(sale); var servedClient = new Client { Name = firstHungryClient.Name, SecondName = firstHungryClient.SecondName, Age = firstHungryClient.Age, TimeOfComing = firstHungryClient.TimeOfComing, IsHungry = false }; _clients.Update(firstHungryClient, servedClient); logger.LogInformation($"[{firstHungryClient.Id}]{firstHungryClient.Name.ToUpper()}" + $" {firstHungryClient.SecondName.ToUpper()}" + $" got a dish {_dishes.Get(randomIdOfDish).Name}" + $" which costs {_dishes.Get(randomIdOfDish).Price}. Bon appetit!"); } } }
private void label5_Click(object sender, EventArgs e) { FormIntrestInProperty formDialog = new FormIntrestInProperty(); ClientProductArr clientProductArr = new ClientProductArr(); clientProductArr.Fill(); ClientProduct clientProduct = new ClientProduct(); //פותח את הדיאלוג ואז בודק האם סגר אותו if (formDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { clientProduct = FormtoClientProduct(); clientProduct.Intrest = formDialog.intrest; if (Convert.ToInt32(labelClientProductID.Text) == 0) { if (clientProduct.Intrest == 0) { clientProduct.ISIntrested = 0; } else { clientProduct.ISIntrested = 1; } if (clientProduct.Insert()) { MessageBox.Show("הוסף בהצלחה", "הוספת עידוכן", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1, MessageBoxOptions.RightAlign | MessageBoxOptions.RtlReading); } else { MessageBox.Show("בעיה בהוספה", "הוספת עידכון", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.RightAlign | MessageBoxOptions.RtlReading); } } else { //עדכון לקוח קיים if (clientProduct.Update()) { MessageBox.Show("עודכן בהצלחה", "עידכון משתמש", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1, MessageBoxOptions.RightAlign | MessageBoxOptions.RtlReading); } else { MessageBox.Show("בעיה בעידכון", "עידכון פרטים", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.RightAlign | MessageBoxOptions.RtlReading); } } } }
public bool Insert() { //מוסיפה את אוסף המוצרים להזמנה למסד הנתונים ClientProduct clientProduct = null; for (int i = 0; i < this.Count; i++) { clientProduct = (this[i] as ClientProduct); if (!clientProduct.Insert()) { return(false); } } return(true); }
public bool Delete() { //מוחקת את אוסף המוצרים להזמנה מ מסד הנתונים ClientProduct clientProduct = null; for (int i = 0; i < this.Count; i++) { clientProduct = (this[i] as ClientProduct); if (!clientProduct.Delete()) { return(false); } } return(true); }
public ClientProductArr Filter(Product product) { ClientProductArr clientProductArr = new ClientProductArr(); for (int i = 0; i < this.Count; i++) { //הצבת המוצר הנוכחי במשתנה עזר - מוצר ClientProduct clientProduct = (this[i] as ClientProduct); if (product == clientProduct.Product) { //המוצר ענה לדרישות החיפוש - הוספה שלו לאוסף המוחזר clientProductArr.Add(clientProduct); } } return(clientProductArr); }
public static ClientProduct ToClientProduct(this ClientProductEntity productEntity, ClientProduct dbmodel = null) { ClientProduct model = dbmodel; if (model == null) { model = new ClientProduct(); } model.Name = productEntity.Name; model.CountryOfOrigin = productEntity.CountryOfOrigin; model.ShelfLife = productEntity.ShelfLife; model.Price = productEntity.Price; model.Amount = productEntity.Amount; model.IsDelivered = productEntity.IsDelivered; model.OrderId = productEntity.OrderId; return(model); }
private void InitializeClientProduct() { ClientProductArr clientProductArr = new ClientProductArr(); clientProductArr.Fill(); Client client = GetClientFromForm(); Product product = GetProductFromForm(); ClientProduct clientProductForId = clientProductArr.FindClientProduct(client, product); if (clientProductForId.Id != 0) { labelClientProductID.Text = Convert.ToString(clientProductForId.Id); } else { labelClientProductID.Text = "0"; } }
public static ClientProductEntity ToClientProductEntity(this ClientProduct model) { if (model == null) { return(null); } ClientProductEntity productEntity = new ClientProductEntity(); productEntity.Id = model.Id; productEntity.OrderId = model.OrderId; productEntity.Name = model.Name; productEntity.CountryOfOrigin = model.CountryOfOrigin; productEntity.ShelfLife = model.ShelfLife; productEntity.Price = model.Price; productEntity.Amount = model.Amount; productEntity.IsDelivered = model.IsDelivered; return(productEntity); }
// POST: Products/Delete/5 public ActionResult Delete(int id) { ClientProduct clientProducts = db.ClientProducts.Where(i => i.ProductId == id).FirstOrDefault(); SupportProduct supportProducts = db.SupportProducts.Where(i => i.ProductId == id).FirstOrDefault(); if (clientProducts != null || supportProducts != null) { TempData["Message"] = "Can not delete this product!"; } else { Product product = db.Products.Find(id); db.Products.Remove(product); db.SaveChanges(); } return(RedirectToAction("Index")); }
public static ClientProduct UpdateProduct(ClientProduct product) { try { var endPointString = endPointQLBH + "api/products"; var productUpdate = Task.Run(() => PutAsync <ClientProduct>(endPointString, product)).Result; return(productUpdate); } catch (BusinessLayerException) { throw new BusinessLayerException(500, "#1001002 Không cập nhật được dữ liệu sản phẩm."); } catch (Exception) { throw new BusinessLayerException(500, "#1001003 Không cập nhật được dữ liệu sản phẩm."); } }
public ActionResult Add(ClientProduct p, HttpPostedFile imgLg, HttpPostedFile imgSm) { //khi hai ô này rỗng if (p.TinyDes == null) { p.TinyDes = string.Empty; } if (p.FullDesRaw == null) { p.FullDesRaw = string.Empty; } p.FullDes = p.FullDesRaw; p.View = 0; //lưu thông tin p = CSDLQLBH.InsertProduct(p); Ulti.SaveProductImgs((int)p.ProID, Server.MapPath("~"), imgLg, imgSm); return(RedirectToAction("Index")); }
public void Fill() { //להביא מה-DAL טבלה מלאה בכל הלקוחות DataTable dataTable = ClientProduct_Dal.GetDataTable(); //להעביר את הערכים מהטבלה לתוך אוסף הלקוחות //להעביר כל שורה בטבלה ללקוח DataRow dataRow; ClientProduct clientProduct; for (int i = 0; i < dataTable.Rows.Count; i++) { dataRow = dataTable.Rows[i]; clientProduct = new ClientProduct(dataRow); this.Add(clientProduct); } }
public ClientProduct FindClientProduct(Client client, Product product) { ClientProduct clientProduct1 = new ClientProduct(); for (int i = 0; i < this.Count; i++) { //הצבת המוצר הנוכחי במשתנה עזר - מוצר ClientProduct clientProduct = (this[i] as ClientProduct); if ( !(client == null || client.ID == -1 || clientProduct.Client.ID != client.ID) //סינון לפי קטגוריה && !(product == null || product.ID == -1 || clientProduct.Product.ID != product.ID)) { //המוצר ענה לדרישות החיפוש - הוספה שלו לאוסף המוחזר clientProduct1 = clientProduct; } } return(clientProduct1); }
// POST: Users/Delete/5 public ActionResult Delete(int id) { ClientProduct client = db.ClientProducts.Where(i => i.UsersId == id).FirstOrDefault(); SupportProduct support = db.SupportProducts.Where(i => i.UsersId == id).FirstOrDefault(); if (client != null || support != null) { TempData["Message"] = "Can not delete this user!"; } else { Users users = db.Users.Find(id); if (users.UserType == "System") { TempData["Message"] = "Can not delete system user!"; } else { db.Users.Remove(users); db.SaveChanges(); } } return(RedirectToAction("Index")); }
public async Task <Alianzas> Create(AllianceDto payload) { var afftype = 1; //setting aff type afftype = await defineAfftype(payload, afftype); //adding productclient to fill required field in aliance var clientProduct = new ClientProduct() { ClientId = payload.ClientId.GetValueOrDefault(), CreatedAt = DateTime.Now, UpdatedAt = DateTime.Now, ProductId = 1, Status = 0 }; await _context.ClientProduct.AddAsync(clientProduct); await _context.SaveChangesAsync(); // creating actual aliance var alianza = new Alianzas() { ClientProductId = clientProduct.Id, QualifyingEventId = payload.QualifyingEventId == null ? 1 : payload.QualifyingEventId.Value, CoverId = payload.CoverId.GetValueOrDefault(), AffType = (byte?)afftype, AffStatus = 1, ElegibleDate = DateTime.Now, StartDate = DateTime.Now, CreatedAt = DateTime.Now, UpdatedAt = DateTime.Now, EndDate = DateTime.Now.AddYears(1), Joint = payload.Joint, Prima = payload.Prima }; //TODO: check if the status of the aliance is complete or pending //for the moment is complete await _context.Alianzas.AddAsync(alianza); await _context.SaveChangesAsync(); alianza = await this.UpdateCost(alianza.Id); foreach (var item in payload.Beneficiaries) { var beneficiary = new Beneficiaries() { Name = item.Name, BirthDate = item.BirthDate, Gender = item.Gender, Percent = item.Percent, Relationship = item.Relationship, CreatedAt = DateTime.Now, UpdatedAt = DateTime.Now, AlianzaId = alianza.Id, Ssn = item.Ssn }; await _context.Beneficiaries.AddAsync(beneficiary); } foreach (var item in payload.AddonList) { var addonId = item; await _context.AlianzaAddOns.AddAsync(new AlianzaAddOns() { AlianzaId = alianza.Id, InsuranceAddOnId = addonId }); } await _context.SaveChangesAsync(); if (alianza.ClientProduct != null) { alianza.ClientProduct.Client.ClientProduct = null; alianza.ClientProduct.Client.ClientUser = null; alianza.ClientProduct.Client.Dependents = null; alianza.ClientProduct.Client.Cover = null; alianza.ClientProduct.Alianzas = null; } alianza.Cover = null; RemoveCircularDependency(ref alianza); alianza.Beneficiaries = null; return(alianza); }
public ClientProductViewModel(MerkatoDbContext context, ClientProduct product) : this(context) { this.Id = product.Id; this.ClientId = product.ClientId; this.ProductName = product.ProductName; }