Beispiel #1
0
 public async void CreateTobacco(HookahTobacco tobacco)
 {
     if (tobacco != null)
     {
         await _mongoDataProvider.Create(tobacco);
     }
 }
Beispiel #2
0
        public string Register()
        {
            // Setup user
            var user = new User();

            try
            {
                // Generate password hash first
                string salt = Randoms.GenerateSalt(8);
                string hash = Hasher.GetHash(Password, salt);
                user.ModelUser                  = new Model.User();
                user.ModelUser.Email            = Email;
                user.ModelUser.Password         = hash;
                user.ModelUser.Basil            = salt;
                user.ModelUser.RegistrationDate = DateTime.Now;
                user.ModelUser.Role             = Constants.Roles.User;
                IDataProvider data = new MongoDataProvider();
                if (data.Create(user.ModelUser) == null)
                {
                    throw new Exception();
                }
            }
            catch (Exception e)
            {
                throw e;
            }

            // Get a session token
            string sessionToken = GetToken(user.ModelUser.Email);

            // if everything passed well
            return(sessionToken);
        }
Beispiel #3
0
        public void CreateCourse()
        {
            var dalCourse = new DAL.Course();

            dalCourse.Author      = "*****@*****.**";
            dalCourse.Description = "Lorem ipsum dolor sit amet";
            dalCourse.Lessons     = new List <Model.Lesson>();
            dalCourse.Name        = "Hello world!";
            dalCourse.Statistics  = new Model.CourseStatistics();
            dalCourse.Subscribed  = new List <string>();

            IDataProvider data = new MongoDataProvider();

            dalCourse = data.Create(dalCourse);
            dalCourse.Identification = dalCourse._id.ToString();

            var modelCourse = new Model.Course();

            modelCourse = dalCourse;
        }
 public async Task CreateTobacco([FromBody] HookahTobacco tobacco)
 {
     await _mongoDataProvider.Create(tobacco);
 }