/// <summary> /// Creates the specified employee. /// </summary> /// <param name="employee">The employee.</param> /// <param name="candidate">The candidate.</param> /// <param name="feedback">The feedback.</param> /// <returns>IMono<Review>.</returns> public static IMono<Review> Create(IMono<Employee> employee, IMono<Candidate> candidate, string feedback) { return candidate.FlatMap( c => employee.FlatMap( e => Mono.Just( new Review { Candidate = c, Employee = e, Date = DateTime.Now, Feedback = feedback }))); }
/// <summary> /// To the authenticated. /// </summary> /// <param name="request">The request.</param> /// <returns>Map to the authenticated.</returns> private Func <User, IMono <AuthenticatedUser> > ToAuthenticated(Credential request) { return(user => user is null || !BCrypt.EnhancedVerify(request.Password, user.Password) ? Mono.Error <AuthenticatedUser>( new ArgumentException("the user or the password are invalid")) : Mono.Just( new AuthenticatedUser(user.Name, user.LastName, user.Email, this.Token(user)))); }
/// <summary> /// The Create instance. /// </summary> /// <param name="server">the server name.</param> /// <returns>The config.</returns> public static IMono <Config> Create(string server) { var validator = new ConfigValidator(); var config = new Config(server); var validation = validator.Validate(config); return(validation.IsValid ? Mono.Just(config) : Mono.Error <Config>(new ArgumentException(string.Join(", ", validation.Errors)))); }
/// <summary> /// Creates the specified name. /// </summary> /// <param name="name">The name.</param> /// <param name="lastName">The last name.</param> /// <param name="email">The email.</param> /// <param name="password">The password.</param> /// <param name="confirm">The confirm.</param> /// <returns>the user.</returns> public static IMono <User> Create(string name, string lastName, string email, string password, string confirm) { if (password != confirm) { return(Mono.Error <User>(new ArgumentException(nameof(confirm)))); } var user = new User(name, lastName, email, BCrypt.Net.BCrypt.EnhancedHashPassword(password)); var validation = new UserValidation(); var valid = validation.Validate(user); return(!valid.IsValid ? Mono.Error <User>(new ArgumentException(string.Join(", ", valid.Errors))) : Mono.Just(user)); }
/// <summary> /// Finds the specified key. /// </summary> /// <param name="key">The key.</param> /// <returns>The entity.</returns> public IMono <T> Find(TK key) => Mono.Just(this.set.Entity <T>().Find(key));