public static string GetValue(string key, XFModel db) { var config = db.Configs.Find(key); return(string.IsNullOrWhiteSpace(config.Value) ? string.Empty : config.Value); }
public async Task <ActionResult> Register(RegisterViewModel model) { if (ModelState.IsValid) { var user = new ApplicationUser { UserName = model.Email, Email = model.Email, FirstName = model.FirstName, LastName = model.LastName, MiddleName = model.MiddleName }; var result = await UserManager.CreateAsync(user, model.Password); if (result.Succeeded) { var db = new XFModel(); db.Logs.Add(new Log() { UserId = User.Identity.GetUserId(), Created = DateTime.Now, Message = string.Format("Adding user | data: {0}", JsonConvert.SerializeObject(new { UserName = model.Email, Name = user.FullName })), Type = "success" }); db.SaveChanges(); // 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", "Users")); } AddErrors(result); } // If we got this far, something failed, redisplay form return(View(model)); }
public StockService(XFModel context) { db = context; }