public bool Login(string email, string password) { using (var dal = new DataAccessLayer()) { var user = dal.Get<UserBase>().FirstOrDefault(x => x.Email == email && x.Password == password); if (user == null) { return false; } _mCachedUser = user; _mCachedSession = dal.Create(new Session { User = _mCachedUser, LastHit = DateTime.UtcNow }); dal.DbContext.SaveChanges(); //remember session id SessionId = _mCachedSession.Id; } return true; }
private void changeByCode(UserBase autorizeUser, Guid userId, Attrib attr) { var isBought = DataAccessLayer.Get<CoinsInfo>(x => x.BuyUser == autorizeUser.Id && x.UserId == userId && x.Code.Code == attr.Code) .FirstOrDefault(); if (isBought == null) { DataAccessLayer.Create<CoinsInfo>(new CoinsInfo() { Id = Guid.NewGuid(), BuyUser = autorizeUser.Id, UserId = userId, Code = attr }); DataAccessLayer.UpdateById<UserBase>(autorizeUser.Id, x => x.Coins = x.Coins - 1); DataAccessLayer.DbContext.SaveChanges(); } }