public async Task <IActionResult> PutUitnodiging(int id, Uitnodiging uitnodiging) { if (id != uitnodiging.UitnodigingID) { return(BadRequest()); } _context.Entry(uitnodiging).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UitnodigingExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult <Uitnodiging> > PostUitnodiging([FromBody] Uitnodiging uitnodiging) { _context.Uitnodigingen.Add(new Uitnodiging { PollID = uitnodiging.PollID, UserID = uitnodiging.UserID }); await _context.SaveChangesAsync(); return(CreatedAtAction("GetUitnodiging", new { id = uitnodiging.UitnodigingID }, uitnodiging)); }
public async Task <ActionResult> Register(RegisterViewModel model) { String fotoId; PhotoInfo fotoInfo; if (ModelState.IsValid) { if (!bs.IsValidKey(model.Key)) { return(RedirectToAction("Login")); } var user = new ApplicationUser { Naam = model.Naam, Voornaam = model.Voornaam }; Uitnodiging u = bs.GetUitnodigingByKey(model.Key); user.Email = u.EmailUitgenodigde; user.UserName = u.EmailUitgenodigde; if (model.Afbeelding != null) { try { fotoId = flickr.UploadPicture(model.Afbeelding.InputStream, model.Email, model.Email, "", "", false, false, false, ContentType.Photo, SafetyLevel.Safe, HiddenFromSearch.Hidden); flickr.PhotosetsAddPhoto(ConfigurationManager.AppSettings.Get("FlickrGebruikersAlbumId"), fotoId); fotoInfo = flickr.PhotosGetInfo(fotoId); user.Afbeelding = fotoInfo.MediumUrl; } catch (Exception ex) { return(RedirectToAction("Index", "Home")); } } var result = await UserManager.CreateAsync(user, model.Password); if (result.Succeeded) { UserManager.SetLockoutEnabled(user.Id, false); UserManager.AddToRole(user.Id, "User"); bs.SetUitnodigingGebruikt(u.Id, user.Email); await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false); // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771 // Send an email with this link // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id); // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme); // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>"); return(RedirectToAction("Index", "Home")); } AddErrors(result); } // If we got this far, something failed, redisplay form return(View(model)); }
public String DeleteUitnodiging(List <int> deleteIds) { if (!User.IsInRole("SuperAdministrator") && !User.IsInRole("Administrator")) { return("fail"); } //TODO: ervoor zorgen dat lege gebruiker ook kan verwijderd worden. foreach (int u in deleteIds) { Uitnodiging a = bs.GetUitnodigingById(u); if (a == null) { return("fail"); } bs.DeleteUitnodiging(a); } return("ok"); }
public ActionResult AddUsers(String Mails) { UitnodigingFeedbackPM fbPM = new UitnodigingFeedbackPM(); Regex regex = new Regex(@"^[\w!#$%&'*+\-/=?\^_`{|}~]+(\.[\w!#$%&'*+\-/=?\^_`{|}~]+)*" + "@" + @"((([\-\w]+\.)+[a-zA-Z]{2,4})|(([0-9]{1,3}\.){3}[0-9]{1,3}))$"); string[] Emails = new string[0]; Emails = Mails.Split(new string[] { "\r\n", ",", " ", ";" }, StringSplitOptions.None); foreach (string m in Emails) { if (regex.Match(m.Trim()).Success) { if (bs.HeeftEmailAlEenUitnodiging(m.Trim())) { if (fbPM.Gebruikt == null) { fbPM.Gebruikt = new List <string>(); } fbPM.Gebruikt.Add(m.Trim()); continue; } Uitnodiging u = bs.CreateUitnodiging(User.Identity.Name, m.Trim()); ApplicationUser zenderNaam = bs.GetUser(User.Identity.Name); UitnodigingSturen(m.Trim(), zenderNaam.Voornaam + " " + zenderNaam.Naam, u.Key); } else { if (fbPM.Foutief == null) { fbPM.Foutief = new List <string>(); } fbPM.Foutief.Add(m.Trim()); } } TempData["Feedback"] = fbPM; return(RedirectToAction("Gebruikers")); }
public string HerzendUitnodiging(int?Id) { if (!Id.HasValue) { return("NOK"); } Uitnodiging u = bs.GetUitnodigingById((int)Id); if (u == null) { return("NOK"); } if (u.Gebruikt) { return("NOK"); } ApplicationUser zenderNaam = bs.GetUser(u.Eigenaar.UserName); UitnodigingSturen(u.EmailUitgenodigde, zenderNaam.Voornaam + " " + zenderNaam.Naam, u.Key); return("OK"); }
public void DeleteUitnodiging(Uitnodiging u) { repoUitnodiging.Delete(u); }