// // GET: /Movies/Create public ActionResult Create() { var vm = new CreateViewModel { Categories = _categoriesSelectList }; return View(vm); }
public void WithoutViewModelRendersWithoutExceptions() { var view = new Create(); var viewModel = new CreateViewModel { Currencies = UnitTestHelper.Currencies.ToList() }; var html = view.RenderAsHtml(viewModel); }
public ActionResult Create() { var viewModel = new CreateViewModel(User.Identity) { Header = "Ask a Question" }; return View("Create", viewModel); }
public ActionResult Create(CreateViewModel vm) { Debugger.Break(); // If things go wrong, repopulate the list of categories vm.Categories = _categoriesSelectList; return View(vm); }
public void WithViewModelRendersWithoutExceptions1() { var view = new Create(); var viewModel = new CreateViewModel { Currencies = new List<string> { "USD", "BTC", "MBUSD" }, CurrencyId = "BTC", DisplayName = null }; var html = view.RenderAsHtml(viewModel); }
public ActionResult Create(CreateViewModel model) { if (!ModelState.IsValid) return View("Index", model); var game = GameService.CreateGame(model, User.Identity.GetUserId()); var db = new Entities(); db.Games.Add(game); db.SaveChanges(); return RedirectToAction("Play", "Game", new { id = game.ID }); }
public ActionResult Create(CreateViewModel createViewModel) { if (this.ModelState.IsValid) { ManufactureOrder order = new CreateViewModelMapper().Map(createViewModel, WorkContext.CurrentUser); this.Storage.GetRepository <IManufactureOrderRepository>().Update(order).Wait(); this.Storage.Save(); return(this.RedirectToAction("index")); } return(this.View()); }
public async Task <IActionResult> Create(CreateViewModel input) { var exam = AutoMapperConfig.MapperInstance.Map <Exam>(input); if (!this.ModelState.IsValid) { return(this.View(input)); } var examId = await this.examService.CreateAsync(input.Name, input.CountQuestion, input.TimeLimit, input.StartTime); this.TempData["Message"] = $"You added Exam with name {input.Name}"; return(this.RedirectToAction("Index", "Dashboard")); }
public async Task <IActionResult> PostToDo([FromBody] CreateViewModel viewModel) { if (!ModelState.IsValid) { return(BadRequest()); } var toDoItem = mapper.Map <ToDoItem>(viewModel); this.repository.AddToDoItem(toDoItem); await this.repository.CommitAsync(); return(CreatedAtRoute(routeName: "CreatedAtRoute", routeValues: new { id = toDoItem.Id }, value: toDoItem)); // return Created("http://localhost/test", null); }
public async Task <CreateViewModel> GetCreateViewModel() { var createVM = new CreateViewModel(); ProjectId = (int)_httpCtxAccessor.HttpContext.Session.GetInt32("projectId"); createVM.Types = await GetTypesSelectItems(); createVM.Status = await GetStatusSelectItems(); createVM.Teams = await GetTeamsSelectItems(); return(createVM); }
public HttpResponse Create(string albumId) { if (!this.IsUserSignedIn()) { return(this.Redirect("/Users/Login")); } var viewModel = new CreateViewModel { AlbumId = albumId, }; return(this.View(viewModel)); }
public ActionResult Create(CreateViewModel viewModel) { var user = CreateUser(viewModel, true, false); if (null == user) { // if we couldn't create the user that means there was some type of validation error, // so redisplay the form with the model return View(viewModel); } repository.SaveChanges(); TempData[GlobalViewDataProperty.PageNotificationMessage] = "The user was created successfully"; return RedirectToAction("Index"); }
public IActionResult Create([FromBody] CreateViewModel model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } int userId = _service.Add(new AppUser { FirstName = model.FirstName, LastName = model.LastName }).ID; return(Ok(userId)); }
public HttpResponse Create(string id) { if (!this.IsUserSignedIn()) { return(this.Redirect("/Users/Login")); } var viewModel = new CreateViewModel { ProblemId = id, Name = this._problemService.GetNameById(id) }; return(this.View(viewModel)); }
public async Task<ActionResult> Create(Guid id, CreateViewModel model) { if (!ModelState.IsValid) { return View(model); } var movementId = await mediator.SendAsync(new CreateImportMovement(id, model.Number, model.ActualShipmentDate.AsDateTime().Value, model.PrenotificationDate.AsDateTime())); return RedirectToAction("Index", "Home", new { area = "AdminImportMovement", id = movementId }); }
public IActionResult Create(CreateViewModel employee) { try { if (ModelState.IsValid) { string uniqueFileName = null; // If the Photo property on the incoming model object is not null, then the user // has selected an image to upload. if (employee.Photo != null) { // The image must be uploaded to the images folder in wwwroot // To get the path of the wwwroot folder we are using the inject // HostingEnvironment service provided by ASP.NET Core string uploadsFolder = Path.Combine("images"); // To make sure the file name is unique we are appending a new // GUID value and and an underscore to the file name uniqueFileName = Guid.NewGuid().ToString() + "_" + employee.Photo.FileName; string filePath = Path.Combine(uploadsFolder, uniqueFileName); // Use CopyTo() method provided by IFormFile interface to // copy the file to wwwroot/images folder if (!Directory.Exists(uploadsFolder)) { Directory.CreateDirectory(uploadsFolder); } employee.Photo.CopyTo(new FileStream(filePath, FileMode.Create)); } var emp = new Employee() { Email = employee.Email, Department = employee.Department.ToString(), Name = employee.Name, PhotoPath = uniqueFileName }; var res = _employeeRepository.Add(emp); return(RedirectToAction("Index")); } return(View()); } catch (Exception ex) { this.logger.LogError(ex.Message); return(RedirectToAction("Error", "Error")); } }
public ActionResult Create(CreateViewModel model) { if (ModelState.IsValid) { string uniqueFileName = null; // If the Photo property on the incoming model object is not null, then the user // has selected an image to upload. if (model.Photo != null) { // The image must be uploaded to the images folder in wwwroot // To get the path of the wwwroot folder we are using the inject // HostingEnvironment service provided by ASP.NET Core string uploadsFolder = Path.Combine(hostingEnvironment.WebRootPath, "images"); // To make sure the file name is unique we are appending a new // GUID value and an underscore to the file name uniqueFileName = Guid.NewGuid().ToString() + "_" + model.Photo.FileName; string filePath = Path.Combine(uploadsFolder, uniqueFileName); // Use CopyTo() method provided by IFormFile interface to // copy the file to wwwroot/images folder model.Photo.CopyTo(new FileStream(filePath, FileMode.Create)); } ViewBag.CategoryId = new SelectList(_CategoryRepository.GetAllCategory(), "Id", "Name"); ViewBag.AuteurId = new SelectList(_AuteurRepository.GetAllAuteurs(), "Id", "Nom"); Livre newLivre = new Livre { Name = model.Name, price = model.price, CategoryId = model.CategoryId, AuteurId = model.AuteurId, PhotoPath = uniqueFileName }; _LivreRepository.Add(newLivre); return(RedirectToAction("details", new { id = newLivre.Id })); } return(View()); }
public async Task CreatePostShouldCallAddItemAsyncWithCorrectParameterIfModelIsValid() { var item = new ToDoItem() { Name = nameof(CreatePostShouldCallAddItemAsyncWithCorrectParameterIfModelIsValid) }; var model = new CreateViewModel() { Name = item.Name }; await ControllerUnderTest.Create(model); MockService.Verify(mock => mock.AddItemAsync(It.Is <ToDoItem>(i => i.Name.Equals(item.Name))), Times.Once); }
public async Task <IActionResult> Borrow(Guid id) { var result = await bookRepository.GetBook(id : id); var model = new CreateViewModel() { BookId = result.BookId, Author = result.Author, DatePublished = result.DatePublished, Pages = result.Pages, Title = result.Title }; return(View(model)); }
public ActionResult Create(CreateViewModel viewModel) { var result = printerModels.Add(viewModel.Name, viewModel.SuppliesCount, viewModel.Comment); if (result.Success) { return(RedirectToAction("Index")); } else { AddModelStateErrors(result); } return(View(viewModel)); }
public IActionResult Create() { var categories = this.categoryService .GetAllCategories <CategoriesDropDownViewModel>(); var authors = this.authorService .GetAuthors <AuthorsDropDownViewModel>(); var model = new CreateViewModel { Categories = categories, Authors = authors, }; return(this.View(model)); }
public ActionResult Create(CreateViewModel model) { if (this.ModelState.IsValid) { model.Map(out AddNasabCommand command); var result = Mediator.Send(command).Result; this.Storage.Save(); return(this.RedirectToAction("index")); } return(this.View()); }
public async Task AddProvider(CreateViewModel providerModel) { Provider provider = new Provider { ProviderName = providerModel.ProviderName, DocumentNumber = providerModel.DocumentNumber, Address = providerModel.Address, PhoneNumber = providerModel.PhoneNumber, Email = providerModel.Email }; _context.Providers.Add(provider); await _context.SaveChangesAsync(); }
public IActionResult Post(CreateViewModel model) { if (this.ModelState.IsValid) { Employee employee = model.ToEntity(); var repo = this.Storage.GetRepository <IEmployeeRepository>(); repo.Create(employee, GetCurrentUserName()); this.Storage.Save(); return(Ok(new { success = true })); } return(BadRequest(new { success = false })); }
public void Does_not_set_Issue_state_abbrev_when_is_not_StateIssue() { // Arrange var vm = new CreateViewModel() { StateAbbrev = "MO", IsStateIssue = false }; // Act Issue issue = vm; // Assert Assert.IsNull(issue.StateAbbrev); }
public ActionResult Create(string id) { using (var ctx = new DataContext()) { if (ctx.Users.Find(id) == null) { id = User.Identity.GetUserId(); } var user = ctx.Users.Find(id); var model = new CreateViewModel(); model.Username = user.Email; return(View(model)); } }
public ActionResult Create(CreateViewModel model) { if (!ModelState.IsValid) { return(View(model)); } if (model.Name.Length > 15) { ModelState.AddModelError(nameof(model.Name), "Max length is 15"); return(View(model)); } return(RedirectToAction(nameof(Edit), new { model.Name })); }
public HttpResponse Create(CreateViewModel model) { var errors = this.validatorService.PackageValidator(model); if (errors.Any()) { return(this.Redirect("/Packages/Create")); } var packageId = this.packageService.Create(model); this.recipientService.Create(packageId); return(this.Redirect("/Packages/Pending")); }
public async Task CreateRoleAsyncTest() { var context = EssayCompetitionContextInMemoryFactory.InitializeContext(); var roleName = "Ninja"; var roleViewModel = new CreateViewModel() { Name = roleName }; var roleRepository = new EfDeletableEntityRepository <ApplicationRole>(context); var service = new RolesService(roleRepository); await service.CreateRoleAsync <CreateViewModel>(roleViewModel.ToQueryable()); Assert.True(roleRepository.All().Any(x => x.Name == roleName), "CreateRoleAsync method does not work correctly"); }
public void Sets_Issue_state_abbrev_when_is_StateIssue() { // Arrange var vm = new CreateViewModel() { StateAbbrev = "MO", IsStateIssue = true }; // Act Issue issue = vm; // Assert Assert.AreEqual("MO", issue.StateAbbrev); }
public ActionResult Create(Guid instanceId, CreateViewModel model) { if (ModelState.IsValid) { var ev = TransferEventFactory.CreateTransfer(instanceId, Guid.NewGuid(), model.ToUserId, model.Sum, model.Date, this.GetAudit()); using (var db = Context.Create()) { db.StoredEvents.Add(StoredEvent.FromEvent(ev)); EventProcessor.Process(db, ev); db.SaveChanges(); return(RedirectToAction("Index", new { instanceId = instanceId })); } } return(View(model)); }
public ActionResult Edit(Guid instanceId, Guid abscenseId, CreateViewModel model) { if (ModelState.IsValid) { using (var db = Context.Create()) { var ev = AbscenseEventFactory.EditAbscense(instanceId, abscenseId, model.Description, model.FromDate, model.ToDate, this.GetAudit()); db.StoredEvents.Add(StoredEvent.FromEvent(ev)); EventProcessor.Process(db, ev); db.SaveChanges(); return(RedirectToAction("Index", new { instanceId })); } } return(View(model)); }
// GET: Reports/CreateTripReport/[WagonTripId] public async Task <IActionResult> CreateTripReport(Guid id) { WagonTrip wagonTrip = await _context.WagonTrips.Include(wt => wt.Wagon).Where(wt => wt.WagonTripId == id).FirstOrDefaultAsync(); Wagon wagon = wagonTrip.Wagon; CreateViewModel model = new CreateViewModel(); model.Report.WagonId = wagon.WagonId; model.Report.Wagon = wagon; model.Report.WagonTripId = wagonTrip.WagonTripId; model.Report.WagonTrip = wagonTrip; ViewData["DeviceTypeId"] = new SelectList(_context.DeviceTypes, "DeviceTypeId", "Name"); return(View("Create", model)); }
public ActionResult Create(Guid instanceId, CreateViewModel model) { if (ModelState.IsValid) { var ev = ExpenseEventFactory.CreateExpense(instanceId, Guid.NewGuid(), model.Category, model.Shop, model.Sum, model.Date, model.AffectedUsers, this.GetAudit()); using (var db = Context.Create()) { db.StoredEvents.Add(StoredEvent.FromEvent(ev)); EventProcessor.Process(db, ev); db.SaveChanges(); return(RedirectToAction("Create", new { instanceId })); } } return(View(model)); }
// // GET: /Admin/FAQ/Edit/5 public async virtual Task <ActionResult> Edit(string id) { FaqObject model = new FaqObject(); model = await FaqManager.GetFaq(id); CreateViewModel viewModel = new CreateViewModel { Id = model.Id, Answer = model.Answer, Question = model.Question }; return(View(viewModel)); }
public async Task <IActionResult> Create([Bind("Description,Title,TimeZone,Culture,Norm")] CreateViewModel viewModel) { if (ModelState.IsValid) { // Map CreateViewModel to Project Mapper.Initialize(cfg => cfg.CreateMap <CreateViewModel, Project>()); Project project = Mapper.Map <Project>(viewModel); project.Owner = await _userManager.GetUserAsync(User); await _projects.CreateProject(project); return(RedirectToAction("List")); } return(View(viewModel)); }
public void NewWordMustBeEmptyWhenCallMethodReset() { var model = new CreateViewModel(null, null); model.NewWord.Name = "name"; model.NewWord.Translate = "ім'я"; model.ResetNewWord(); Assert.AreEqual(model.NewWord.Name, null); Assert.AreEqual(model.NewWord.Translate, null); Assert.AreEqual(model.NewWord.SourcePicture.UriSource.ToString(), Resource.getInstance().SourceNoImage.UriSource.ToString()); Assert.AreEqual(model.NewWord.Example, null); Assert.AreEqual(model.NewWord.WordPriority, model.NewWord.Priorities[0]); }
// GET: TrainTrips/CreateForTrain/[TrainId] public IActionResult CreateForTrain(int?id) { ViewData["ReporterId"] = new SelectList(_context.Reporters, "ReporterId", "UserName"); //ViewData["TrainId"] = new SelectList(_context.Trains, "TrainId", "Name"); CreateViewModel model = new CreateViewModel(); model.TrainTrip.Train = _context.Trains.Find(id); List <Wagon> wagons = _context.Wagons.OrderBy(w => w.Name).ToList(); foreach (Wagon w in wagons) { model.Wagons.Add(w.Name, false); } return(View(model)); }
public ActionResult Create(CreateViewModel model) { if (ModelState.IsValid) { try { _leagueManagementService.Create(model.Title); return RedirectToAction("Index", "League"); } catch (InvalidEntityException e) { ModelState.AddModelError("", e.Message); } } return View(); }
public static Game CreateGame(CreateViewModel model, string hostUserID) { var game = new Game(); game.Name = model.Name; game.NumPlayers = model.NumPlayers; if (model.Private) game.Password = HashPassword(model.Password); game.HostedByUserID = hostUserID; game.HasStarted = false; game.HasFinished = false; game.CreatedOn = DateTime.Now; return game; }
public override void Given() { viewModel = new CreateViewModel(); viewModel.ConfirmPassword = "******"; viewModel.Password = "******"; viewModel.Username = "******"; viewModel.FirstName = "user"; viewModel.LastName = "user"; viewModel.Email = "*****@*****.**"; membershipService.Setup(s => s.CreateUser(viewModel.Username, viewModel.Password, viewModel.FirstName, viewModel.LastName, viewModel.Email, true, false)) .Callback<string, string, string, string, string, bool, bool>((username, password, firstName, lastName, email, isApproved, isLocked) => { user = new User(username, password, firstName, lastName, email); user.IsApproved = isApproved; user.IsLocked = isLocked; }).Returns(() => user); }
public ActionResult Create(Vinyl vinyl) { CreateViewModel model = new CreateViewModel(); model.Vinyl = vinyl ?? new Vinyl(); HttpResponseMessage artistResponse = ArtistsGateway.ReadAll(); if (!artistResponse.IsSuccessStatusCode) return new HttpStatusCodeResult(artistResponse.StatusCode); model.Artists = artistResponse.Content.ReadAsAsync<IEnumerable<Artist>>().Result; HttpResponseMessage genreResponse = GenresGateway.ReadAll(); if (!genreResponse.IsSuccessStatusCode) return new HttpStatusCodeResult(genreResponse.StatusCode); model.Genres = genreResponse.Content.ReadAsAsync<IEnumerable<Genre>>().Result; return View(model); }
public ActionResult Create(CreateViewModel model) { Contract.Requires<InvalidOperationException>(this.ClientService != null); Contract.Requires<InvalidOperationException>(this.SessionPersister != null); Contract.Requires<ArgumentNullException>(model != null, "model"); if (!this.SessionPersister.HasSession) { return this.RedirectToLogin(); } if (this.ModelState.IsValid) { var accountId = this.ClientService.CreateCurrentAccount( this.SessionPersister.SessionId, model.CurrencyId, model.DisplayName); return this.RedirectToAction(string.Empty); } model.Currencies = this.CurrencyCache.Currencies; return this.View(model); }
public async Task<ActionResult> Create(Guid id, CreateViewModel model) { if (!ModelState.IsValid) { return View(model); } var success = await mediator.SendAsync(new CreateMovementInternal(id, model.Number, model.PrenotificationDate.AsDateTime(), model.ActualShipmentDate.AsDateTime().Value, model.HasNoPrenotification)); if (success) { var movementId = await mediator.SendAsync(new GetMovementIdByNumber(id, model.Number)); return RedirectToAction("Index", "InternalCapture", new { area = "AdminExportMovement", id = movementId }); } ModelState.AddModelError("Number", CaptureMovementControllerResources.SaveUnsuccessful); return View(model); }
public ActionResult Create(CreateViewModel model) { var page = _pageService.CreatePage(model.ParentId, model.PagePath, model.Title, model.Content, 0); if (_authorizer.CanCreateBelow(page) || _authorizer.CanCreatePages()) { return View("Created", page); } return this.RedirectToWikiPage(page); }
public ActionResult Create() { var viewModel = new CreateViewModel(); return View(viewModel); }
public override void Given() { viewModel = new CreateViewModel(); viewModel.Username = username; viewModel.Password = "******"; viewModel.ConfirmPassword = "******"; viewModel.Email = "*****@*****.**"; viewModel.FirstName = "test"; viewModel.LastName = "test"; membershipService.Setup(s => s.UsernameIsInUse(username)).Returns(true); }
public override void Given() { viewModel = new CreateViewModel(); viewModel.Username = username; viewModel.Password = "******"; viewModel.ConfirmPassword = "******"; viewModel.Email = userEmail; viewModel.FirstName = "test"; viewModel.LastName = "test"; user = new User(viewModel.Username, viewModel.Password, viewModel.FirstName, viewModel.LastName, viewModel.Email); membershipService.Setup(s => s.CreateUser(username, viewModel.Password, viewModel.FirstName, viewModel.LastName, viewModel.Email, false, false)).Returns(user); var role = new Role(Roles.Administrators); user = new User("officer", "officer", "officer", "user", "*****@*****.**"); role.Users.Add(user); repository.Init<Role>(new List<Role> { role }.AsQueryable()); }
public override void Given() { viewModel = new CreateViewModel(); viewModel.Username = username; }
public ActionResult Create() { var dropdownlist_Cruise_Property = new CreateViewModel.DropDownList_Cruise() { Cruises = CruiseService.GetCruises().ToList() }; var dropdownlist_Trip_Property = new CreateViewModel.DropDownList_Trip() { Trips = TripService.GetTrips().ToList() }; var dropdownlist_VoucherTemplate_Property = new CreateViewModel.DropDownList_VoucherTemplate() { VoucherTemplates = VoucherTemplateService.GetVoucherTemplates().ToList() }; var createViewModel = new CreateViewModel() { DropDownList_Cruise_Property = dropdownlist_Cruise_Property, DropDownList_Trip_Property = dropdownlist_Trip_Property, DropDownList_VoucherTemplate_Property = dropdownlist_VoucherTemplate_Property }; return View(createViewModel); }
public override void Given() { viewModel = new CreateViewModel(); controller.ModelState.AddModelError("Username", new Exception("test")); }
public ActionResult Create(CreateViewModel createViewModel) { if (!ModelState.IsValid) { return View(createViewModel); } var trip = new Trip() { Name = createViewModel.Name, Description = createViewModel.Description, TripCode = createViewModel.TripCode, NumberOfDay = createViewModel.NumberOfDay != null ? createViewModel.NumberOfDay.Value : 0 }; TripService.CreateTrip(trip); TempData["TripId"] = trip.TripId; TempData["TripName"] = trip.Name; TempData["Message"] = TripsMessage.CreateSuccess; return RedirectToAction("index", "trips"); }
public ActionResult Create(CreateViewModel createViewModel) { if (!ModelState.IsValid) { return View(createViewModel); } var selectedTrip = TripService.FindById(createViewModel.DropDownList_Trip_Property.SelectedTrip); var selectedCruise = CruiseService.FindById(createViewModel.DropDownList_Cruise_Property.SelectedCruise); var selectedVoucherTemplate = VoucherTemplateService.FindById(createViewModel.DropDownList_VoucherTemplate_Property.SelectedVoucherTemplate); var voucherBatch = new VoucherBatch() { Name = createViewModel.Name, Description = createViewModel.Description, ValidUntil = createViewModel.ValidUntil, IssueDate = createViewModel.IssueDate, Note = createViewModel.Note, Value = createViewModel.Value, Trip = selectedTrip, TripId = createViewModel.DropDownList_Trip_Property.SelectedTrip != -1 ? (int?)createViewModel.DropDownList_Trip_Property.SelectedTrip : null, Cruise = selectedCruise, CruiseId = createViewModel.DropDownList_Cruise_Property.SelectedCruise != -1 ? (int?)createViewModel.DropDownList_Cruise_Property.SelectedCruise : null, VoucherTemplate = selectedVoucherTemplate, VoucherTemplateId = createViewModel.DropDownList_VoucherTemplate_Property.SelectedVoucherTemplate != -1 ? (int?)createViewModel.DropDownList_VoucherTemplate_Property.SelectedVoucherTemplate : null }; VoucherBatchService.CreateVoucherBatch(voucherBatch); var voucherCodes = (List<string>)TempData["VoucherCodes"]; for (int i = 0; i < voucherCodes.Count(); i++) { var voucherCode = new VoucherCode() { VoucherCodeString = voucherCodes.ToArray()[i], VoucherBatchId = voucherBatch.VoucherBatchId, VoucherBatch = voucherBatch }; if (voucherCode.VoucherBatch != null) { voucherCode.VoucherBatchId = voucherCode.VoucherBatch.VoucherBatchId; } else { voucherCode.VoucherBatchId = null; } VoucherCodeService.CreateVoucherCode(voucherCode); } TempData["VoucherBatchId"] = voucherBatch.VoucherTemplateId; TempData["VoucherBatchName"] = voucherBatch.Name; TempData["Message"] = VoucherBatchesMessage.CreateSuccess; return RedirectToAction("index", "voucherbatches"); }
protected User CreateUser(CreateViewModel viewModel, bool approved, bool locked) { if (!ModelState.IsValid) { return null; } if (membershipService.UsernameIsInUse(viewModel.Username)) { // the username is in use ModelState.AddModelErrorFor<CreateViewModel>(m => m.Username, "The username is already in use"); return null; } if (membershipService.EmailIsInUse(viewModel.Email)) { // the email address is in use ModelState.AddModelErrorFor<CreateViewModel>(m => m.Email, "The email address is already in use"); return null; } var user = membershipService.CreateUser(viewModel.Username, viewModel.Password, viewModel.FirstName, viewModel.LastName, viewModel.Email, approved, locked); return user; }
public ActionResult Create(PagePath id, string title = null) { if (!User.IsInRole(WikiRole.Contributor)) return View("MayNotCreate"); var model = new CreateViewModel { PagePath = id, Title = title ?? id.Name, Content = "", Templates = new List<SelectListItem>(), }; var parent = _repository.Get(id.ParentPath); if (parent != null) { model.ParentId = parent.Id; model.ParentPath = parent.PagePath.ToString(); if (parent.ChildTemplate != null) { model.TemplateId = parent.ChildTemplate.Id; model.Content = parent.ChildTemplate.Content; } } model.Templates = _templateRepository.Find().Select(x => new SelectListItem { Selected = x.Id == model.TemplateId, Text = x.Title, Value = x.Id.ToString( CultureInfo.InvariantCulture) }); return View(model); }
public ActionResult SignUp(CreateViewModel viewModel, bool captchaValid) { if (!captchaValid) { ModelState.AddModelError("captcha", "Incorrect. Try again."); return View(viewModel); } var user = CreateUser(viewModel, false, false); if (null == user) { // if we couldn't create the user that means there was some type of validation error, // so redisplay the form with the model return View(viewModel); } try { SendNewUserAwaitingApprovalEmail(user); } catch (System.Net.Mail.SmtpException e) { // log mail exception but don't let it interrupt the process ErrorSignal.FromCurrentContext().Raise(e); } repository.SaveChanges(); return RedirectToAction("SignUpComplete"); }