Kaynağa Gözat

Fixed issue where entity object was being used twice in the same scope.

tags/2.0.3
Teknikode 4 yıl önce
ebeveyn
işleme
9edb326304

+ 3
- 3
Teknik/Areas/Profile/Controllers/ProfileController.cs Dosyayı Görüntüle

@@ -191,7 +191,7 @@ namespace Teknik.Areas.Profile.Controllers
{
if (Config.UserConfig.RegistrationEnabled)
{
if (Utility.UserHelper.UserExists(model.Username))
if (Utility.UserHelper.UserExists(db, model.Username))
{
return Json(new { error = "That username already exists." });
}
@@ -276,7 +276,7 @@ namespace Teknik.Areas.Profile.Controllers
{
if (ModelState.IsValid)
{
User user = Utility.UserHelper.GetUser(User.Identity.Name);
User user = Utility.UserHelper.GetUser(db, User.Identity.Name);
if (user != null)
{
string email = string.Format("{0}@{1}", User.Identity.Name, Config.EmailConfig.Domain);
@@ -428,7 +428,7 @@ namespace Teknik.Areas.Profile.Controllers
}

// Delete User
User user = Utility.UserHelper.GetUser(User.Identity.Name);
User user = Utility.UserHelper.GetUser(db, User.Identity.Name);
if (user != null)
{
user.UserSettings = db.UserSettings.Find(user.UserId);

+ 3
- 5
Teknik/Areas/Profile/Utility/UserHelper.cs Dosyayı Görüntüle

@@ -13,18 +13,16 @@ namespace Teknik.Areas.Profile.Utility
{
public static class UserHelper
{
public static User GetUser(string username)
public static User GetUser(TeknikEntities db, string username)
{
TeknikEntities db = new TeknikEntities();

User user = db.Users.Where(b => b.Username == username).FirstOrDefault();

return user;
}

public static bool UserExists(string username)
public static bool UserExists(TeknikEntities db, string username)
{
User user = GetUser(username);
User user = GetUser(db, username);
if (user != null)
{
return true;

Loading…
İptal
Kaydet