//On "Add" button clicked private void button2_Click(object sender, EventArgs e) { Deposit newDeposit; if (IsConstructedObjectValid(out newDeposit)) { bool isAdded = true; try { _deposits.Add(newDeposit); } catch (Exception exception) { MessageBox.Show("Failure! " + exception.Message); isAdded = false; } if (isAdded) { MessageBox.Show(string.Format( "Successfully created a deposit with name {0} for " + "bank {1}", newDeposit.Name, newDeposit.Bank.Name)); ResetFields(); ReloadDataGridViewData(); } } }
public IActionResult AddComment(BlogComment blogComment) { blogComment.DateAdded = DateTime.Now; _blogComments.Add(new BlogComment[] { blogComment }); return(RedirectToAction("Details", new { id = blogComment.BlogPostId })); }
public async Task <IActionResult> Create([Bind("Name,Destination,TransportationPrice,AccomodationPrice,AdventuresPrice")] TourPackage tourPackage) { if (ModelState.IsValid) { _tourPackages.Add(tourPackage); return(RedirectToAction(nameof(Index))); } return(View(tourPackage)); }
public async Task <IActionResult> Create([Bind("Id,Name")] Bank bank) { if (ModelState.IsValid) { _banks.Add(bank); return(RedirectToAction(nameof(Index))); } return(View(bank)); }
public async Task <IActionResult> Create(Deposit deposit) { if (ModelState.IsValid) { _deposits.Add(deposit); return(RedirectToAction(nameof(Index))); } return(View(deposit)); }
public async Task <IActionResult> Create([Bind("Id,Name,Make,Description,Stock,Price,IsInSale,SalePrice,ThumbnailSource")] Product product) { if (ModelState.IsValid) { _products.Add(product); return(RedirectToAction(nameof(Index))); } return(View(product)); }
public async Task <IActionResult> Create([Bind("Id,BankId,Name,MinAmount,Interest,PaymentMethod,Currency")] Deposit deposit) { if (ModelState.IsValid) { _deposits.Add(deposit); return(RedirectToAction(nameof(Index))); } return(View(deposit)); }
public async Task RegisterRss(string uri, int bgId) { XDocument rssString = await RssToXDocument(uri); if (rssString != null) { string source = Guid.NewGuid().ToString(); _data.Add( new RssFeed { Active = true, Url = uri, StandardBackground = _data.GetSingle <Background>(bgId), Source = source, PublicationDate = rssString.Root.Descendants("channel").Elements("pubDate").First().Value .ParseDate(), Title = rssString.Root.Descendants("channel").Elements("title").First().Value, Description = rssString.Root.Descendants("channel").Elements("description").First().Value }); _data.Commit(); } }
public async Task <IActionResult> Create(Data.Models.Faq faq) { if (ModelState.IsValid) { _faqs.Add(faq); return(RedirectToAction(nameof(Index))); } var errors = ModelState.Select(x => x.Value.Errors) .Where(y => y.Count > 0) .ToList(); return(View(faq)); }
public async Task <IActionResult> CreateComment([FromBody] TourPackageComment tourPackageComment) { if (ModelState.IsValid) { tourPackageComment.DateCreated = DateTime.Now; //check for currently logged in user var existingUser = await _users.FindByNameAsync(tourPackageComment.Username.ToLower()); //check if user is in database if (null != existingUser) { tourPackageComment.Username = existingUser.UserName; tourPackageComment.User = existingUser; } _tourPackageComments.Add(tourPackageComment); return(Ok()); } return(NotFound()); }
public IActionResult Create(BlogPost blogPost) { _blogPosts.Add(blogPost); return(RedirectToAction("Index")); }