public IActionResult CreateLot(LotViewModel model) { byte[] imageData = null; using (var binaryReader = new BinaryReader(model.AvatarLot.OpenReadStream())) { imageData = binaryReader.ReadBytes((int)model.AvatarLot.Length); } string a = _userManager.GetUserId(User); Lot lot = new Lot { LotName = model.LotName, Discription = model.Discription, StartCost = model.StartCost, CurrentCost = model.StartCost, AvatarLot = imageData, User = _user.GetUserDB(_userManager.GetUserId(User)), UserId = _userManager.GetUserId(User), OwnerName = User.Identity.Name, Status = true, }; _lot.AddLotDB(lot); return(RedirectToAction("MyLots", "Lot")); }
void loadLots() { rt = LotORM.listeLots(); myDataObjectLot = new LotViewModel(); lotComboBox.ItemsSource = rt; //LIEN AVEC la VIEW }
public async Task <IActionResult> EditLot(LotViewModel model) { if (ModelState.IsValid) { Lot lot = _lot.GetLotDB(model.Id); byte[] imageData = null; using (var binaryReader = new BinaryReader(model.AvatarLot.OpenReadStream())) { imageData = binaryReader.ReadBytes((int)model.AvatarLot.Length); } if (lot != null) { lot.LotName = model.LotName; lot.Discription = model.Discription; lot.StartCost = model.StartCost; lot.AvatarLot = imageData; _lot.UpdateLot(lot); return(RedirectToAction("MyLots", "Lot")); } } return(View(model)); }
public ActionResult EditLot(LotViewModel viewModel, string returnUrl) { viewModel.ModifidedDateTime = DateTime.Now; viewModel.Direction = viewModel.DirectionText == Messages.MessagesConstant.Increase.ToString() ? DirectionOfLot.Increase : DirectionOfLot.Decrease; viewModel.Duration = viewModel.Duration.HasValue ? DateTimeConstant.MinDate.AddHours(viewModel.Duration.Value.Hour) .AddMinutes(viewModel.Duration.Value.Minute) .AddSeconds(viewModel.Duration.Value.Second) : (DateTime?)null; string error; if (!_auctionProvider.EditLot(viewModel, out error)) { Logger.Debug(Messages.LogsConstant.TheLotEdited.Format(viewModel.Context, Session.GetUserId())); return(RedirectToAction("DetailsTemplate", "Auctions", new { id = viewModel.AuctionTemplateId })); } Logger.Debug(Messages.LogsConstant.TheLotEditedMistake.Format(viewModel.Context, Session.GetUserId(), error)); ModelState.AddModelError("", Messages.MessagesConstant.TheLotEditedMistake.Format(viewModel.Context, Session.GetUserId(), error)); return(View()); }
public bool CreateLot(LotViewModel viewModel, out string error) { var res = false; error = null; try { using (DbFactory.CreateUnitOfWork()) { var lot = new Lot { Id = Guid.NewGuid(), AuctionTemplateId = viewModel.AuctionTemplateId, Context = viewModel.Context, Duration = viewModel.Duration, Direction = viewModel.Direction, StartingPrice = viewModel.StartingPrice, CreateDateTime = viewModel.CreateDateTime, ModifidedDateTime = viewModel.ModifidedDateTime }; DbFactory.Lots.Save(lot); } } catch (Exception e) { res = true; error = e.Message; } return(res); }
public ActionResult Edit(LotViewModel model) { if (ModelState.IsValid) { try { Lot lot = model.ToDomain(); lot.SetUser(Convert.ToInt32(HttpContext.User.Identity.Name)); Response response = services.LotService.Save(lot); if (response.Error) { this.ErrorMessage = response.Message; } else { this.SuccessMessage = response.Message; } return(PartialView("_Form", model)); } catch (Exception ex) { TempData["ErrorMessage"] = ex.Message; } } return(PartialView("_Form", model)); }
public static LotViewModel getLot(int idLot) { LotDAO pDAO = LotDAO.getLot(idLot); LotViewModel p = new LotViewModel(pDAO.id_lot, pDAO.id_vente_enchere, pDAO.description); return(p); }
public ActionResult Lot(LotViewModel lotView) { if (ModelState.IsValid == false) { return(View("Lot", lotView)); } var actualLot = _crudLotService.GetLotById(lotView.Id); if (actualLot != null) { lotView.CurrentPrice = actualLot.CurrentPrice; lotView.MinimalStepRate = actualLot.MinimalStepRate; } if (lotView.PriceRate < lotView.CurrentPrice + lotView.MinimalStepRate) { ModelState.AddModelError("", "Price your rate should be more that minimal step"); return(View("Lot", lotView)); } _lotService.MakeRate(lotView.Id, lotView.CurrentUserId, lotView.PriceRate); return(RedirectToAction("Index", "LotManager")); }
public ActionResult Edit(LotViewModel model, int categoryId, HttpPostedFileBase image = null) { if (User.IsInRole("User") && model.State == LotStateViewModel.ForSale || model.State == LotStateViewModel.Sold) { return(RedirectToAction("UserPanel", "User")); } if (image == null) { var lot = _lotService.GetLotEntity(model.Id); model.ImageData = lot.ImageData; model.ImageType = lot.ImageType; } else { model.ImageType = image.ContentType; model.ImageData = new byte[image.ContentLength]; image.InputStream.Read(model.ImageData, 0, image.ContentLength); } if (ModelState.IsValid) { model.CategoryId = categoryId; model.StartDate = model.StartDate + new TimeSpan(DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second); _lotService.UpdateLot(model.ToBllLot()); return(RedirectToAction("AdminPanel", "Admin")); } SelectList categoriesList = new SelectList(_categoryService.GetAllCategoryEntities(), "Id", "Name", _categoryService.GetCategoryEntity((int)model.CategoryId)); ViewBag.CategoriesList = categoriesList; return(View(model)); }
public static LotViewModel getLot(int idLot) { LotDAO pDAO = LotDAO.getLot(idLot); LotViewModel p = new LotViewModel(pDAO.idLotDAO, pDAO.nomLotDAO, pDAO.descriptionLotDAO, pDAO.idEnchereLotDAO); return(p); }
public bool EditLot(LotViewModel viewModel, out string error) { var res = false; error = null; try { using (DbFactory.CreateUnitOfWork()) { var lot = DbFactory.Lots.GetById(viewModel.Id); lot.Context = viewModel.Context; lot.Duration = viewModel.Duration; lot.Direction = viewModel.Direction; lot.StartingPrice = viewModel.StartingPrice; lot.ModifidedDateTime = viewModel.ModifidedDateTime; DbFactory.Lots.Save(lot); } } catch (Exception e) { res = true; error = e.Message; } return(res); }
public ActionResult Create(LotViewModel lot) { if (ModelState.IsValid) { if (lot.EndDate < DateTime.Now) { ModelState.AddModelError(string.Empty, "End Date cannot come before Now"); return(View(lot)); } if (lot.MinimalBid < 0.01m) { ModelState.AddModelError(string.Empty, "Starting bid can't be less than 0.1"); return(View(lot)); } if ((lot.BuyOutBid != null) && (lot.BuyOutBid.Value <= lot.MinimalBid)) { ModelState.AddModelError(string.Empty, "Buyout bid can't be less than or equal to starting bid!"); return(View(lot)); } lot.CreatedByUserId = UserViewModel.Id; WebImage wi = WebImage.GetImageFromRequest(); if (wi != null) { wi.Resize(300, 300, true, true); lot.LotPicture = wi.GetBytes(); wi.Resize(100, 100, true, true); lot.LotPicturePreview = wi.GetBytes(); } _lotService.CreateLot(lot.ToLotEntity()); return(RedirectToAction("Index")); } return(View(lot)); }
public FileResult GetImage(int?lotId, bool?isPreview) { WebImage wi; bool preview = true; if (isPreview.HasValue) { preview = isPreview.Value; } if (lotId.HasValue) { LotViewModel lot = _lotService.GetLotEntity(lotId.Value).ToLotViewModel(); if (lot.LotPicture != null) { wi = new WebImage(preview ? lot.LotPicturePreview : lot.LotPicture); } else { wi = GetDefaultImage(preview); } } else { wi = GetDefaultImage(preview); } return(File(wi.GetBytes(), "image/" + wi.ImageFormat, wi.FileName)); }
void loadLots() { lp = LotORM.listeLots(); myDataObject = new LotViewModel(); //LIEN AVEC la VIEW listeLots.ItemsSource = lp; // bind de la liste avec la source, permettant le binding. }
private void LotButton_Click(object sender, RoutedEventArgs e) { try { myDataObjectLot.idLotProperty = LotDAL.getMaxIdLot() + 1; lot.Add(myDataObjectLot); LotORM.insertLot(myDataObjectLot); compteur = lot.Count(); /*listeLot.Items.Refresh();*/ myDataObjectLot = new LotViewModel(); nomTextBox.DataContext = myDataObjectLot; descriptionTextBox.DataContext = myDataObjectLot; idEnchereComboBox.DataContext = myDataObjectLot; /*idLotTextBox.DataContext = myDataObjectLot;*/ LotButton.DataContext = myDataObjectLot; } catch (Exception ex) { MessageBox.Show("A handled exception just occurred: " + ex.Message, "Exception Sample", MessageBoxButton.OK, MessageBoxImage.Warning); } }
void loadLot() { lot = LotORM.listeLot(); myDataObjectLot = new LotViewModel(); //LIEN AVEC la VIEW /*listeLot.ItemsSource = lot; // bind de la liste avec la source, permettant le binding.#1#*/ }
public async Task <ActionResult> EditLot(Guid tenderGuid, string lotId) { var lotDTO = await TenderProvider.GetLot(tenderGuid, lotId); var viewModel = new LotViewModel(tenderGuid, lotDTO); return(View(viewModel)); }
public IActionResult CreateLot() { var vm = new LotViewModel { UserId = UserId, Categories = GetCategoriesSelectListItems() }; return(View(vm)); }
public static bool ToLeaderOnChangedRate(LotViewModel model, string newLeader) { /*var membershipUser = Membership.GetUser(model.LeaderName); * return membershipUser != null && SendEamil(membershipUser.Email, model.Name, * String.Format( * "Hello, {0} \r\n Your bid on lot <a href=\"{1}/Lot/Index/{2}\"> {3} </a>, was broken by <a href=\"{1}/localhost/OnlineAuction/Account/Profile?name={4}\"> {4} </a>", * model.LeaderName, LOCAL, model.ID, model.Name, newLeader)); */ return(false); }
public static bool ToLeaderOnComplete(LotViewModel model) { //var membershipUser = Membership.GetUser(model.LeaderName); //return membershipUser != null && SendEamil(membershipUser.Email, model.Name, // String.Format( // "Hello, {0} \r\n Congratulations? you won lot {1} by $ {2}! \r\n " + // "Wait until you contact the seller", // model.LeaderName, model.Name, model.Currency)); return(false); }
private void Btn_Sppr(object sender, RoutedEventArgs e) { if (List_Lot.SelectedItem is LotViewModel) { LotViewModel toRemove = (LotViewModel)List_Lot.SelectedItem; lp.Remove(toRemove); List_Lot.Items.Refresh(); LotORM.supprimerLot(selectedLotId); } }
private void supprimerLot(object sender, RoutedEventArgs e) { if (listeLots.SelectedItem is LotViewModel) { LotViewModel toRemove = (LotViewModel)listeLots.SelectedItem; lp.Remove(toRemove); listeLots.Items.Refresh(); LotORM.supprimerLot(selectedLotsId); } }
public ActionResult DeleteLot(LotViewModel model) { var lotid = Convert.ToInt32(Request.Cookies["LotId"].Value); if (Auction.DeleteLot(lotid)) { return(RedirectToAction("Index", "Home")); } ModelState.AddModelError("", "Fail while model deleting."); return(RedirectToAction("Index", new { id = lotid })); }
public static bool ToOwnerOnComplete(LotViewModel model) { //var membershipUser = Membership.GetUser(model.OwnerId); //TODO: сделать нормальный поиск пользователей //return membershipUser != null && SendEamil(membershipUser.Email, model.Name, // String.Format( // "Hello, {0} \r\n Your lot {1}, was won by the user {2} by $ {4}. \r\n " + // "Contact them for contacts listed in the user's profile:" + // " {3}/OnlineAuction/Account/Profile?name={2}", // model.OwnerName, model.Name,leadername,LOCAL,model.Currency)); return(false); }
public async Task <ActionResult> EditLot(LotViewModel viewModel) { if (!ModelState.IsValid) { return(View(viewModel)); } var lotDTO = viewModel.ToModelDTO(); await TenderProvider.EditLot(viewModel.TenderGuid, lotDTO); return(RedirectToAction("Info", "TenderInfo", new { tenderGuid = viewModel.TenderGuid })); }
public ActionResult CreateLot(Guid?id) { if (!id.HasValue) { return(RedirectToAction("AuctionTemplates", "Auctions")); } var model = new LotViewModel { AuctionTemplateId = id.Value }; return(View(model)); }
public static ObservableCollection <LotViewModel> listeLot() { ObservableCollection <LotDAO> lDAO = LotDAO.listeLot(); ObservableCollection <LotViewModel> l = new ObservableCollection <LotViewModel>(); foreach (LotDAO element in lDAO) { LotViewModel p = new LotViewModel(element.idLotDAO, element.nomLotDAO, element.descriptionLotDAO, element.idEnchereLotDAO); l.Add(p); } return(l); }
public static ObservableCollection <LotViewModel> listeLots() { ObservableCollection <LotDAO> lDAO = LotDAO.listeLots(); ObservableCollection <LotViewModel> l = new ObservableCollection <LotViewModel>(); foreach (LotDAO element in lDAO) { LotViewModel p = new LotViewModel(element.id_lot, element.id_vente_enchere, element.description); l.Add(p); } return(l); }
public ActionResult Update(LotViewModel lot) { if (UserViewModel == null) { return(new HttpStatusCodeResult(401)); } if ((UserViewModel.Id != lot.CreatedByUserId) && (!_customAuthentication.CheckUserInRoles(UserViewModel.ToUserEntity(), "Admin,Moderator"))) { return(new HttpStatusCodeResult(403)); } var oldLot = _lotService.GetLotEntity(lot.Id); ViewBag.HasImage = oldLot.LotPicture != null; lot.CreatedByUserId = oldLot.CreatedByUserId; if (ModelState.IsValid) { if (lot.EndDate < DateTime.Now) { ModelState.AddModelError(string.Empty, "End Date cannot come before Now"); return(View(lot)); } if (lot.MinimalBid < 0.01m) { ModelState.AddModelError(string.Empty, "Starting bid can't be less than 0.1"); return(View(lot)); } if ((lot.BuyOutBid != null) && (lot.BuyOutBid.Value <= lot.MinimalBid)) { ModelState.AddModelError(string.Empty, "Buyout bid can't be less than or equal to starting bid!"); return(View(lot)); } WebImage wi = WebImage.GetImageFromRequest(); var r = wi; if (wi != null) { wi.Resize(300, 300, true, true); lot.LotPicture = wi.GetBytes(); wi.Resize(100, 100, true, true); lot.LotPicturePreview = wi.GetBytes(); } if ((wi == null) && (!lot.DeletePicture)) { lot.LotPicture = oldLot.LotPicture; lot.LotPicturePreview = oldLot.LotPicturePreview; } _lotService.UpdateLot(lot.ToLotEntity()); return(RedirectToAction("Details", new { id = lot.Id })); } return(View(lot)); }
public IActionResult CreateLot(LotViewModel vm) { if (ModelState.IsValid) { vm.ImageUrl = SaveImage(vm.ImageFile, HttpContext.RequestServices.GetRequiredService <IHostingEnvironment>()); var lot = _lotsService.AddItem(vm.ToDto()); return(RedirectToAction(nameof(Lots), lot.LotId)); } vm.Categories = GetCategoriesSelectListItems(vm.CategoryId); return(View(vm)); }