public ActionResult _AddNewInterest() { user = db.Users.Where(e => e.UserPseudonym == User.Identity.Name).First(); ViewBag.Interests = user.Interests; return View(); }
public ActionResult _AddNewInterest(string interest) { try { Interest inter = new Interest(); inter.Text = interest; db.Interests.Add(inter); db.SaveChanges(); inter = db.Interests.Where(e => e.InterestID == inter.InterestID).First(); user = db.Users.Where(e => e.UserPseudonym == User.Identity.Name).First(); user.Interests.Add(inter); db.Entry(user).State = EntityState.Modified; db.SaveChanges(); TempData["Status"] = "Interest has been added!"; } catch (Exception e) { TempData["Status"] = "An error occured!"; } return RedirectToAction("Profile"); }
public ActionResult _EvilCalendar(string shTitle, string shTxt, DateTime time) { try { user = db.Users.Where(e => e.UserPseudonym == User.Identity.Name).First(); Plan plan = new Plan() { PlanTitle = shTitle, PlanBody = shTxt, Time = time}; db.Plans.Add(plan); user.Plans.Add(plan); db.Entry(user).State = EntityState.Modified; db.SaveChanges(); TempData["Status"] = "Plan has been added!"; } catch (Exception e) { TempData["Status"] = "An error occured!"; } return RedirectToAction("Profile"); }
public ActionResult _EvilCalendar() { user = db.Users.Where(e => e.UserPseudonym == User.Identity.Name).First(); ViewBag.Plans = this.filterPlan(user.Plans).ToList(); return View(); }
public UserPageController() { user = new DemonsUser(); }
public ActionResult _UploadFile(HttpPostedFileBase upload) { try { user = db.Users.Where(e => e.UserPseudonym == User.Identity.Name).First(); if (upload != null && upload.ContentLength > 0) { AvatarFile avatar = new AvatarFile { ContentType = upload.ContentType }; using (var reader = new BinaryReader(upload.InputStream)) { avatar.Content = reader.ReadBytes(upload.ContentLength); } user.Avatar = avatar; } db.Entry(user).State = EntityState.Modified; db.SaveChanges(); TempData["Status"] = "Avater has been added!"; } catch (Exception e) { TempData["Status"] = "An error occured!"; } return RedirectToAction("Profile"); }
public ShopController() { db = new EFContext(); user = new DemonsUser(); }
public ActionResult _AddItem(ShopItem shopItem, HttpPostedFileBase upload) { try { if (ModelState.IsValid) { user = db.Users.Where(e => e.UserPseudonym == User.Identity.Name).First(); if (upload != null && upload.ContentLength > 0) { AvatarFile img = new AvatarFile { ContentType = upload.ContentType }; using (var reader = new BinaryReader(upload.InputStream)) { img.Content = reader.ReadBytes(upload.ContentLength); } shopItem.Img = img; } db.ShopItems.Add(shopItem); db.SaveChanges(); TempData["Status"] = "Item successfully added."; } } catch (Exception e) { TempData["Status"] = "An error occured!"; } ViewBag.ListOfType = constans.GetTypes(); return View(); }
public async Task<ActionResult> Register(RegisterViewModel model) { if (ModelState.IsValid) { var user = new ApplicationUser { UserName = model.Login, Email = model.Email }; var result = await UserManager.CreateAsync(user, model.Password); if (result.Succeeded) { DemonsUser demon = new DemonsUser(); demon.UserPseudonym = model.Login; demon.UserEmail = model.Email; UserDatabase.Users.Add(demon); UserDatabase.SaveChanges(); 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); }