public IActionResult PlaceOrder(PizzaViewModel pvm) { CrustModel c = new CrustModel() { Name = pvm.Crust }; SizeModel s = new SizeModel() { Name = pvm.Size }; ToppingModel t = new ToppingModel() { Name = pvm.Toppings[0].Name }; PizzaModel p = new PizzaModel() { Crust = c, Size = s, Topping = new List <ToppingModel>() { t } }; OrderModel o = new OrderModel() { Pizzas = new List <PizzaModel>() { p } }; _db.Orders.Add(o); return(RedirectToPage("/Home Page")); }
public HttpResponseMessage AddProductSize(int pid, SizeModel model, string token) { try { using (ShoppingELFEntities context = new ShoppingELFEntities()) { SellerTable seller = new SellerTable(); string username = TokenManager.ValidateToken(token); seller = context.SellerTable.FirstOrDefault(x => x.email == username); if (seller != null && seller.Role == "Seller") { bool x = new ProductRepository().AddProductSize(pid, model); if (x) { return(Request.CreateResponse(HttpStatusCode.OK, "Product Size Added")); } else { return(Request.CreateResponse(HttpStatusCode.BadRequest, "Their is some problem adding the product size")); } } else { return(Request.CreateResponse(HttpStatusCode.Unauthorized, "Access to this page is denied")); } } } catch (Exception ex) { return(Request.CreateResponse(HttpStatusCode.BadRequest, ex)); } }
public IActionResult SaveEntity(SizeModel colorVM) { var _message = ""; try { if (colorVM.Id > 0) { var status = _sizeService.SaveEntity(colorVM); _message = status == true ? "Cập nhật thành công" : "Cập nhật không thành công"; } else { var status = _sizeService.SaveEntity(colorVM); _message = status == true ? "Thêm mới thành công" : "Thêm mới không thành công"; } _sizeService.Save(); return(new OkObjectResult(new { status = true, message = _message })); } catch (Exception ex) { return(new OkObjectResult(new { status = false, message = "có lỗi xảy ra" })); } }
public async Task <IActionResult> Edit(int id, [Bind("IdSize,NumSize")] SizeModel sizeModel) { if (id != sizeModel.IdSize) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(sizeModel); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SizeModelExists(sizeModel.IdSize)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(sizeModel)); }
protected void btnSubmit_Click(object sender, EventArgs e) { SizeModel model = new SizeModel(); Size s = createSize(); labelResult.Text = model.InsertSize(s); }
public HttpResponseMessage EditProduct(int pid, SizeModel model, string token) { try { using (ShoppingELFEntities context = new ShoppingELFEntities()) { SellerTable seller = new SellerTable(); string username = TokenManager.ValidateToken(token); seller = context.SellerTable.FirstOrDefault(x => x.email == username); if (seller != null && seller.Role == "Seller") { bool x = new ProductRepository().EditProduct(pid, model); if (x) { return(Request.CreateResponse(HttpStatusCode.OK, "Product Details Updated successfully")); } else { return(Request.CreateResponse(HttpStatusCode.BadRequest, "Something Went Wrong , please try again later")); } } else { return(Request.CreateResponse(HttpStatusCode.Unauthorized, "Access to this page is denied")); } } } catch (Exception ex) { return(Request.CreateResponse(HttpStatusCode.BadRequest, ex)); } }
/** * For internal use **/ public void SizeMessage(string message) { Debug.Log("SizeMessage received:" + message); SizeModel model = new SizeModel(message); OnSize(model); }
public bool SaveEntity(SizeModel sizeModel) { try { if (sizeModel.Id > 0) { var size = GetSizeById(sizeModel.Id).ToColor(); size.Id = sizeModel.Id; size.Name = sizeModel.Name; size.UpdatedDate = DateTime.Now; _sizeRepository.Update(size); return(true); } else { var size = new Size(); size.Id = sizeModel.Id; size.Name = sizeModel.Name; size.CreatedDate = DateTime.Now; _sizeRepository.Add(size); return(true); } } catch (Exception ex) { return(false); } }
public IHttpActionResult GetFilesSize(int itemId) { string path = "D:\\work\\"; if (itemId == -1 || _size == null) { path = "D:\\work\\"; } else { foreach (var directory in _size.directories) { if (directory.id == itemId) { path = directory.path; break; } } } _size = new SizeModel(); _size.initClass(); DirectoryInfo derictories = new DirectoryInfo(path); _size.fullPath = derictories.FullName; _size.parentPath = derictories.Parent.FullName; startChekFile(path); createFilesInfo(path); createDirectoriesInfo(path); return(Ok(_size)); }
public AddOrderSizeViewModel() { _sizemodel = SizeModel.getInstance(); People = new People(); Citys = _sizemodel.GetCitites(); OnPropertyChanged("People"); OnPropertyChanged("Citys"); }
void Add(object obj) { _sizemodel = SizeModel.getInstance(); if (_sizemodel.AddLimit(Limit.GetCopy())) { Close(obj, true); } }
public AModel Update(PizzaModel pizza, CrustModel crust, SizeModel size, List <ToppingModel> toppings) { pizza.Crust = crust; pizza.Size = size; pizza.Toppings = toppings; return(pizza); }
public IActionResult GetSize() { var data = new SizeModel() { Size = Db.ShortLinks.Count(), }; return(Ok(data)); }
public AddLimitViewModel() { _sizemodel = SizeModel.getInstance(); Limit = new CitiesLimit { Date = DateTime.Now.Date }; City = _sizemodel.GetCitites(); OnPropertyChanged("City"); }
public static SizeViewModel ToViewModel(this SizeModel model) { return(new SizeViewModel { SizeId = model.SizeId, Name = model.Name, Diameter = model.Diameter }); }
public async Task <ActionResult> DeleteSize(int sizeId) { SizeModel size = await this._sizeRepository.DeleteSizeAsync(sizeId); if (size != null) { TempData["message"] = string.Format("Размер \"{0}\" был удален!", size.Name); } return(RedirectToAction("ListSizes")); }
public async Task <IActionResult> Create([Bind("IdSize,NumSize")] SizeModel sizeModel) { if (ModelState.IsValid) { _context.Add(sizeModel); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(sizeModel)); }
public void EditSize(SizeModel size) { var sizeInDb = GetSizeById(size.SizeId); if (sizeInDb != null) { sizeInDb.Name = size.Name; sizeInDb.Diameter = size.Diameter; _dbContext.Update(sizeInDb); _dbContext.SaveChanges(); } }
public async Task <RedirectToRouteResult> RemoveFromCart(Cart cart, CartLineViewModel model) { GoodsModel goods = await this.repository.GetGoodsByIdAsync(model.goodsId); SizeModel size = await this.sizeRepository.GetSizeByIdAsync((int)model.sizeId); if (goods != null) { cart.RemoveLine(goods, size); } return(RedirectToAction("Index", new { model.returnUrl })); }
private void ResetForm() { Price = 0; FactureDetails = new BindableCollection <FactureDetailsModel>(); FactureDetailsList = new List <FactureDetailsModel>(); //Fill Sizes SizeModel size = new SizeModel(); Sizes = size.GiveCollection(size.All()); Cleared = false; Delivery = DateTime.UtcNow.Date; }
//public int Limitz //{ get { return CitysLimits.Limit; } } //public static ObservableCollection<CitiesLimit> Limitzz //{ // get // { // ApplicationContext context = new ApplicationContext(); // return new ObservableCollection<CitiesLimit>(context.CitiesLimits.Select(s => s).ToList()); // } //} public EditSizeOrderViewModel(People people) { _sizeModel = SizeModel.getInstance(); People = people.GetCopy(); City = _sizeModel.GetCitites(); LimitsC = _sizeModel.GetCitiestLimit(); GetCityLimitsTable(); OnPropertyChanged("Peoples"); OnPropertyChanged("City"); //OnPropertyChanged("CitiesLimitss"); // OnPropertyChanged("Limitzz"); }
public void Update() { if (Size != null && Size != string.Empty) { this._size_model.Size = this.Size; this._size_model = this._size_model.UpdateThis(); MessageBox.Show("Size Updated", "Success", MessageBoxButton.OK, MessageBoxImage.Information); } else { MessageBox.Show("Empty Size", "Failed", MessageBoxButton.OK, MessageBoxImage.Error); } }
void Add(object obj) { _sizemodel = SizeModel.getInstance(); if (_sizemodel.AddCity(new Cities { CityName = CityName })) { Close(obj, true); } //if (_model.AddGroup(new Group { Name = Name })) // Close(obj, true); }
public async Task <ActionResult> EditSize(int?sizeId) { if (sizeId != null) { SizeModel size = await this._sizeRepository.GetSizeByIdAsync((int)sizeId); if (size != null) { return(View(size)); } return(RedirectToAction("ListSizes")); } return(HttpNotFound()); }
public SizeModel GetSizeById(int id) { var size = new SizeModel(); if (id > 0) { size = _sizeRepository.Queryable() .Where(r => r.Id == id) .AsNoTracking() .FirstOrDefault() .ToModel(); } return(size); }
public async Task <ActionResult> EditSize(SizeModel size) { if (ModelState.IsValid) { await this._sizeRepository.SaveSizeAsync(size); TempData["message"] = string.Format("Изменения в размере \"{0}\" были сохранены", size.Name); return(RedirectToAction("ListSizes")); } else { return(View(size)); } }
public async Task SaveSizeAsync(SizeModel size) { if (size.SizeId == 0) { this._context.Sizes.Add(Mapper.Map <SizeModel, Size>(size)); } else { Size newSize = await this._context.Sizes.FindAsync(size.SizeId); newSize.Name = size.Name; } await this._context.SaveChangesAsync(); }
/// <summary> /// TODO: /// </summary> /// <param name="id"></param> /// <returns></returns> public async Task <bool> SaveSize(SizeModel model) { var entity = model.MapTo <Size>(); if (model.Id < 1) { await _repository.Insert(entity); } else { await _repository.Update(entity); } return(true); }
public void Save() { if (Size != null && Size != string.Empty) { SizeModel sm = new SizeModel() { Size = this.Size, }; sm = sm.SaveThis(); MessageBox.Show("Size Created", "Success", MessageBoxButton.OK, MessageBoxImage.Information); } else { MessageBox.Show("Empty Size", "Failed", MessageBoxButton.OK, MessageBoxImage.Error); } }
public async Task <RedirectToRouteResult> AddToCart(Cart cart, CartLineViewModel model) { if (model.sizeId != null) { GoodsModel goods = await this.repository.GetGoodsByIdAsync(model.goodsId); SizeModel size = await this.sizeRepository.GetSizeByIdAsync((int)model.sizeId); if (goods != null) { cart.AddItem(goods, size, Convert.ToInt32(model.quantity)); } return(RedirectToAction("Index", new { model.returnUrl })); } TempData["message"] = "Выберите размер"; return(RedirectToAction("GetGoodsDescription", "Goods", new { goodsId = model.goodsId })); }