public async Task <IActionResult> OpenLot(string id) { if (!string.IsNullOrWhiteSpace(id)) { AuctionLot lot = (await lotLogic.Read(new AuctionLot { Id = id })).First(); lot.Bids = await bidLogic.Read(new Bid { AuctionLotId = id }); User user = await userManager.FindByNameAsync(User.Identity.Name); SavedList userList = await savedListLogic.Read(user); if (userList.AuctionLots.Any(lot => lot.Id == id)) { ViewBag.IsSaved = true; } else { ViewBag.IsSaved = false; } if (lot == null) { return(NotFound()); } return(View(lot)); } return(NotFound()); }
public async Task <IActionResult> Register(RegisterViewModel model) { if (ModelState.IsValid) { if (!string.IsNullOrWhiteSpace(model.TelegramId)) { User sameTelegramUser = (await userLogic.Read(new User { TelegramUsername = model.TelegramId }))?.FirstOrDefault(); if (sameTelegramUser != null) { ModelState.AddModelError(string.Empty, "Уже есть пользователь с таким Telegram-идентификатором"); return(View(model)); } } User user = new User { Email = model.Email, UserName = model.UserName, TelegramUsername = string.IsNullOrWhiteSpace(model.TelegramId) ? string.Empty : model.TelegramId, TelegramChatId = string.Empty }; var registerResult = await userManager.CreateAsync(user, model.Password); if (registerResult.Succeeded) { user.Email += ApplicationConstantsProvider.AvoidValidationCode(); user.UserName += ApplicationConstantsProvider.AvoidValidationCode(); await userManager.AddToRoleAsync(user, "regular user"); await savedListLogic.Create(user); await signInManager.SignInAsync(user, false); return(View("Redirect", new RedirectModel { InfoMessages = RedirectionMessageProvider.AccountCreatedMessages(), RedirectUrl = "/Home/Lots", SecondsToRedirect = ApplicationConstantsProvider.GetShortRedirectionTime() })); } else { foreach (var error in registerResult.Errors) { ModelState.AddModelError(string.Empty, error.Description); } } } return(View(model)); }
public async Task <IActionResult> CheckLot(string id) { if (!string.IsNullOrWhiteSpace(id)) { AuctionLot lotToCheck = (await crudLotLogic.Read(new AuctionLot { Id = id }))?.First(); return(View(new LotModerationModel { AuctionLot = lotToCheck })); } return(NotFound()); }