Esempio n. 1
0
        public async Task <ActionResult> Create(Pass pass)
        {
            pass.CreatedOn = DateTime.UtcNow;
            _passContext.Add(pass);
            await _passContext.SaveChangesAsync();

            return(RedirectToAction("Index", new { skiCardId = pass.CardId }));
        }
Esempio n. 2
0
        public async Task <IActionResult> Signup([FromBody] Login val)
        {
            UserDataContext userDatadb = new UserDataContext();
            UserNContext    userNamedb = new UserNContext();
            PassContext     passworddb = new PassContext();

            //At this stage we have no userData besides the ID
            //Creating this object automatically generates an ID
            UserDataDB userData = new UserDataDB();

            //Create new username and password database entries with the same key
            UserNDB userName = new UserNDB(userData.UserId);

            userName.Email    = val.email;
            userName.UserName = val.username;
            PassDB password = new PassDB(userData.UserId);

            password.Password = val.password;

            userDatadb.Add(userData);
            userNamedb.Add(userName);
            passworddb.Add(password);

            //update the databases
            try
            {
                userDatadb.SaveChanges();
                userNamedb.SaveChanges();
                passworddb.SaveChanges();
            }
            catch (DbUpdateException)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError));
            }

            return(Ok(200));

            //string newUser = JsonSerializer.Serialize(val);
            //bool complete = await be.incomming(1, 3, newUser);
            //bool complete = true;
            //if (complete)
            //{
            //    return Ok(200);
            //}
            //return BadRequest(400);
        }
Esempio n. 3
0
        public void Should_be_invalid_if_current_time_is_after_valid_date()
        {
            _mockDateService.Setup(x => x.Now()).Returns(new DateTime(2012, 01, 01));
            var passType = new PassType
            {
                ValidFrom = new DateTime(2010, 01, 01),
                ValidTo   = new DateTime(2011, 01, 01)
            };

            _passTypeContext.PassTypes.Add(passType);
            _passTypeContext.SaveChanges();
            var pass = new Pass
            {
                CreatedOn  = DateTime.UtcNow,
                PassTypeId = passType.Id
            };

            _passContext.Add(pass);
            _passContext.SaveChanges();
            var checker = GetInstance();

            Assert.False(checker.IsValid(pass.Id));
        }