public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Description")] TypeProduct typeProduct) { if (id != typeProduct.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(typeProduct); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TypeProductExists(typeProduct.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(typeProduct)); }
public async Task <string> PutTypeProduct(int id, TypeProduct typeProduct) { if (id != typeProduct.Id) { return("0"); } _context.Entry(typeProduct).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TypeProductExists(id)) { return("0"); } else { throw; } } return("{\"id\":" + id + ",\" stt\":\"" + typeProduct.Status + "\"}"); }
public Article(ushort code, string name, uint price, TypeProduct type) { this.CodeProduct = code; this.NameProduct = name; this.Price = price; this.type = type; }
public async Task <IActionResult> PutTypeProduct([FromRoute] int id, [FromBody] TypeProduct typeProduct) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != typeProduct.TypeProductId) { return(BadRequest()); } _context.Entry(typeProduct).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TypeProductExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public void Delete(Guid?Id) { TypeProduct model = db.TypeProducts.Find(Id); db.TypeProducts.Remove(model); db.SaveChanges(); }
public IHttpActionResult PutTypeProduct(int id, TypeProduct typeProduct) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != typeProduct.Id) { return(BadRequest()); } // db.Entry(typeProduct).State = EntityState.Modified; db.MarkAsModified(typeProduct); try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!TypeProductExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public EditProductViewModel() { SaveChangesCommand = new LambdaCommand(OnSaveChangesCommandExecuted, CanSaveChangesCommandExecuted); CancelCommand = new LambdaCommand(OnCancelCommandExecuted, CanCancelCommandExecuted); #region Для прогрузки var frms = Application.Current.Windows; for (int i = 0; i < frms.Count; i++) { var bb = frms[i].DataContext; if (bb != null) { var b = frms[i].DataContext.ToString(); if (b == "MVVMTest.ViewModels.JobWindowViewModel") { product = (bb as JobWindowViewModel).selecterdProduct; } } } List <Unit> Units = sklad.Units.ToList(); UnitsEntries = new CollectionView(Units); List <TypeProduct> typeProducts = sklad.TypeProducts.ToList(); TypenEtries = new CollectionView(typeProducts); _typeEntry = product.TypeProduct; _unitEntry = product.Unit; #endregion }
public async Task <ActionResult <TypeProduct> > PostTypeProduct(TypeProduct typeProduct) { _context.typeProduct.Add(typeProduct); await _context.SaveChangesAsync(); return(CreatedAtAction("GetTypeProduct", new { id = typeProduct.Id }, typeProduct)); }
public bool Equals(Product other) { if (other == null) { return(false); } else { if (!TypeProduct.Equals(other.TypeProduct)) { return(false); } if (!NameProduct.Equals(other.NameProduct)) { return(false); } if (!PriceProduct.Equals(other.PriceProduct)) { return(false); } if (!QuantityProduct.Equals(other.QuantityProduct)) { return(false); } } return(true); }
public void Post([FromBody] TypeProduct tp) { using (var context = new WebServiceDBContext()) { context.TypeProduct.Add(tp); context.SaveChanges(); } }
public void Put([FromBody] TypeProduct tp) { using (var context = new WebServiceDBContext()) { context.Entry(tp).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); } }
public IActionResult CreateTypeProduct(TypeProduct model) { if (ModelState.IsValid) { _typeProduct.Add(model); return(RedirectToAction("Index")); } return(View(model)); }
/// <summary> /// Constructeur de la classe /// </summary> /// <param name="n">Type du boost</param> /// <param name="price">prix du produit</param> /// <param name="quantity">Quantité du produit </param> /// <param name="elasticité">élasticité de vente du produit</param> public Product(TypeProduct n, double price, int quantity, double elasticité) { this.resalePrice = atBuyPrice; this.lastPrice = this.resalePrice; this.name = n; this.atBuyPrice = price; this.quantity = quantity; this.elasticité = elasticité; }
static void AddStore(string[] masNameProduct, List <Store> stores, TypeProduct typeProduct) { Random rd = new Random(); foreach (string txt in masNameProduct) { stores.Add(new Store(txt, rd.Next(10, 70), typeProduct)); } }
public void Execute(string[] args, string enteredCommandKey) { TypeProduct item = new TypeProduct(); Console.Write("Write type names - "); item.TypeName = Console.ReadLine(); unitOfWork.TypeProducts.Create(item); Console.WriteLine("Added"); }
public async Task <CreatorProductDTO> GetInfoProductAsync(TypeProduct typeProduct) { VMCreator creatorEntity = await _vMCreatorRepository.FirstOrDefaultAsync(x => x.TypeProduct == typeProduct); if (creatorEntity == null) { throw new ApplicationException("This product cannot be created"); } return(_mapper.Map <VMCreator, CreatorProductDTO>(creatorEntity)); }
public ActionResult Edit(int id) { TypeProduct typeProduct = unitOfWork.TypeProducts.Get(id); if (typeProduct == null) { return(HttpNotFound()); } return(View(typeProduct)); }
public ActionResult Create(TypeProduct tp) { if (ModelState.IsValid) { unitOfWork.TypeProducts.Create(tp); unitOfWork.Save(); return(RedirectToAction("Index")); } return(View(tp)); }
public async Task <IActionResult> Create([Bind("Id,Name,Status")] TypeProduct typeProduct) { if (ModelState.IsValid) { _context.Add(typeProduct); await _context.SaveChangesAsync(); } TempData["typeProductresult"] = "Thêm mới thành công"; return(RedirectToAction("Index")); }
public IActionResult DeleteTypeProduct(TypeProduct model) { var typeProduct = _context.TypeProducts.Where(x => x.Id == model.Id).FirstOrDefault(); if (typeProduct != null) { _context.TypeProducts.Remove(typeProduct); _context.SaveChanges(); } return(RedirectToAction("Index")); }
public ActionResult Create([Bind(Include = "Name")] TypeProduct typeProduct) { if (ModelState.IsValid) { db.TypeProducts.Add(typeProduct); db.SaveChanges(); return(RedirectToAction("Index")); } return(RedirectToAction("Index")); }
public IHttpActionResult GetTypeProduct(int id) { TypeProduct typeProduct = db.TypeProducts.Find(id); if (typeProduct == null) { return(NotFound()); } return(Ok(typeProduct)); }
public TypeProduct Get(long id) { TypeProduct tp = null; using (var context = new WebServiceDBContext()) { tp = context.TypeProduct.Find(id); } return(tp); }
public async Task <IActionResult> Create([Bind("Id,Name,Description")] TypeProduct typeProduct) { if (ModelState.IsValid) { _context.Add(typeProduct); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(typeProduct)); }
public Article(uint codeProduct, string name = "", int price = 1, TypeProduct type = TypeProduct.TypeFirst) { _codeProduct = 0; _name = ""; _price = 0; _type = 0; CodeProduct = codeProduct; Name = name; Price = price; Type = type; }
public HttpResponseMessage Delete(long id) { using (var context = new WebServiceDBContext()) { TypeProduct tp = context.TypeProduct.Find(id); context.Entry(tp).State = System.Data.Entity.EntityState.Deleted; context.SaveChanges(); } return(new HttpResponseMessage(HttpStatusCode.Accepted)); }
public IHttpActionResult PostTypeProduct(TypeProduct typeProduct) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.TypeProducts.Add(typeProduct); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = typeProduct.Id }, typeProduct)); }
public async Task <IActionResult> Create(TypeProduct typeProducts) { if (ModelState.IsValid) { _db.Add(typeProducts); await _db.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(typeProducts)); }
public async Task <IActionResult> PostTypeProduct([FromBody] TypeProduct typeProduct) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.TypeProduct.Add(typeProduct); await _context.SaveChangesAsync(); return(CreatedAtAction("GetTypeProduct", new { id = typeProduct.TypeProductId }, typeProduct)); }
public IActionResult Put(Guid id, [FromBody] TypeProduct updateProduct) { try { repository.Update(updateProduct); unitOfWork.SaveChanges(); return(Ok(true)); } catch { throw; } }
public ActionResult SalvarProducto(Product product, string TypeName, string BrandName) { ViewBag.Message = "Productos"; if (!string.IsNullOrEmpty(TypeName)) { var oldType = this.DataService.TypeProductRepository.CreateQuery(Proyection.Basic) .Where(TypeProductFields.TypeProductName, TypeName).ToList().FirstOrDefault(); if (oldType == null) { TypeProduct type = new TypeProduct(); type.TypeProductName = TypeName; SaveEntity(type); product.TypeProductId = type.TypeProductId; } else { product.TypeProductId = oldType.TypeProductId; } } if (!string.IsNullOrEmpty(BrandName)) { var oldBp = this.DataService.BrandProductRepository.CreateQuery(Proyection.Basic) .Where(BrandProductFields.BrandProductName, BrandName).ToList().FirstOrDefault(); if (oldBp == null) { BrandProduct bp = new BrandProduct(); bp.BrandProductName = BrandName; SaveEntity(bp); product.BrandProductId = bp.BrandProductId; } else { product.BrandProductId = oldBp.BrandProductId; } } SaveEntity(product); return this.Json(new { result = "success" }); }
public ActionResult SalvarTypeProduct(TypeProduct type) { ViewBag.Message = "Tipos de Productos"; SaveEntity(type); return View("Nuevo", type); }