Beispiel #1
0
        public IHttpActionResult Index(LoginModel model)
        {
            try
            {
                MusicianBusiness musicianBusiness = new MusicianBusiness();

                Musician user = musicianBusiness.Login(model.email, model.password);

                if (user == null)
                {
                    return(Unauthorized());
                }

                BearerToken bearerLogin = new BearerToken(new BearerDatabaseManager(model.email));
                bearerLogin.GenerateHeaderToken(user.id.ToString(), user.email);

                return(Ok(user));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.StackTrace));

                return(InternalServerError(ex));
            }
        }
Beispiel #2
0
        public void Musician_SearchByName()
        {
            MusicianBusiness musicianBusiness = new MusicianBusiness();
            var musicians = musicianBusiness.SearchByName("Julia");

            bool ok = musicians.Count() > 0;

            Assert.IsTrue(ok);
        }
Beispiel #3
0
        public void TestMethod1()
        {
            string email    = "*****@*****.**";
            string password = "******";

            MusicianBusiness musicianBusiness = new MusicianBusiness();

            Musician user = musicianBusiness.Login(email, password);

            BearerToken bearerLogin = new BearerToken();

            bearerLogin.GenerateHeaderToken(user.id.ToString(), user.email);
        }
Beispiel #4
0
        public void Musician_Create()
        {
            Login();

            MusicianBusiness musicianBusiness = new MusicianBusiness();
            Musician         musician         = new Musician
            {
                name       = faker.Person.FullName,
                email      = faker.Person.Email.ToLower(),
                password   = faker.Internet.Password(),
                birth_date = faker.Date.Between(new DateTime(1925, 1, 1), new DateTime(1997, 12, 31))
            };

            var retorno = musicianBusiness.Create(musician);

            bool ok = retorno.id > 0;

            Assert.IsTrue(ok);
        }
Beispiel #5
0
        public void Login()
        {
            string name = "Teste User", email = "*****@*****.**", password = "******";

            MusicianBusiness musicianBusiness = new MusicianBusiness();
            Musician         musician = musicianBusiness.Login(email, password);

            if (musician == null)
            {
                musician = new Musician
                {
                    name     = name,
                    email    = email,
                    password = password
                };

                musician = musicianBusiness.Create(musician);
            }

            loggedUser = musician;
        }
Beispiel #6
0
 public MusicianModel()
 {
     musicianBusiness = new MusicianBusiness();
 }
Beispiel #7
0
        internal IEnumerable <Musician> Musicians(int musical_project_id)
        {
            MusicianBusiness contributionBusiness = new MusicianBusiness();

            return(contributionBusiness.GetByMusicalProjectId(musical_project_id));
        }