public IActionResult Create([FromBody] Session session)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (session == null)
            {
                return(BadRequest("Sesssion Model is Null"));
            }

            var newSession = _repository.AddSession(session);

            return(StatusCode(201, newSession));
        }
Beispiel #2
0
        public void GivenOneSessionInTheStore_WhenQueriedForExistingParkingFacility_ThenReturnInvoiceListWithOneElement()
        {
            var startDateTime = new DateTime(2018, 12, 15, 12, 25, 0);

            _sessionsRepository.AddSession(new Domain.Session
            {
                CustomerId        = "some customer",
                ParkingFacilityId = "pf001",
                StartDateTime     = startDateTime,
                EndDateTime       = startDateTime.AddHours(1)
            });

            var result = GetSut().GetInvoices("pf001");

            var invoice = Assert.Single(result);

            Assert.NotNull(invoice);
            Assert.Equal("pf001", invoice.ParkingFacilityId);
            Assert.Equal("some customer", invoice.CustomerId);
        }
Beispiel #3
0
        public ActionResult LogIn(LogInModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }

            User currentUser = repo.getUser(model.UserName, model.Password);

            if (!(currentUser == null))
            {
                if (sessRepo.GetUserSession(currentUser.Name) == null)
                {
                    //пользователь еще не залогинен
                    sessRepo.AddSession(new UserSession {
                        Name = currentUser.Name, Status = "Online"
                    });
                }
                ClaimsIdentity identity = new ClaimsIdentity(
                    new[] {
                    new Claim(ClaimTypes.Name, currentUser.Name),
                    new Claim(ClaimTypes.Email, currentUser.Email)
                },
                    "ApplicationCookie");

                IOwinContext           ctx         = Request.GetOwinContext();
                IAuthenticationManager authManager = ctx.Authentication;

                authManager.SignIn(identity);

                return(Redirect(GetRedirectUrl(model.ReturnUrl)));
            }

            ModelState.AddModelError("", "Invalid user name or password");

            return(View());
        }
 public ActionResult Post(Session value)
 {
     _sessionsRepository.AddSession(value);
     return(Ok());
 }