public AuthenticationResponse Save(Authentication authentication) { authentication.Code = Guid.NewGuid().ToString(); authentication.Created = DateTime.Now; authentication.Updated = DateTime.Now; _authentications.Add(authentication); return authentication; }
public string Authenticate(Authentication authentication) { if (authentication == null) throw new ArgumentNullException("authentiation"); //User Exists? var user = _users.GetByUserName(authentication.UserName); if (user == null) return null; authentication.UserId = user.Id; //Password Matches? user.Password = authentication.Password; if (!_hasher.IsValid(user)) return null; var result = _authentications.Save(authentication); return result.Code; }
public AuthenticationResponse Save(Authentication authentication) { authentication.Code = Guid.NewGuid().ToString(); var query = new DapperQuery(ConnectionString) { Sql = @"INSERT INTO UserAuthentication([Code], [UserId], [Truck]) VALUES (@Code, @UserId, @Truck)", Parameters = new { Code = authentication.Code, UserId = authentication.UserId, Truck = authentication.Truck } }; QueryExecutor.Execute(query); return authentication; }