public void HasProhibitedObject()
        {
            int id                 = 1;
            int idAlien            = 1;
            int idBallad           = 1;
            int?idObjectNotAllowed = 1;

            var checkInCheckOut = new CheckInCheckOut(id, idAlien, idBallad, idObjectNotAllowed);

            Assert.True(checkInCheckOut.HasObjectNotAllowed());
        }
        public IActionResult PutCheckOut(int id, [FromBody] CheckInCheckOut checkInCheckOut)
        {
            var checkoutDoBanco = _context.CheckInCheckOuts.SingleOrDefault(e => e.Id == checkInCheckOut.Id);

            checkInCheckOut.CheckOut();
            checkoutDoBanco.DateTimeExit = checkInCheckOut.DateTimeExit;

            _context.SaveChanges();

            return(NoContent());
        }
        public void MinimumCheckOutTime()
        {
            int id                 = 1;
            int idAlien            = 1;
            int idBallad           = 1;
            int idObjectNotAllowed = 1;
            var dateTimeExit       = DateTime.Now.AddMinutes(-1);

            var checkInCheckOut = new CheckInCheckOut(id, idAlien, idBallad, idObjectNotAllowed);

            Assert.True(checkInCheckOut.MinimumCheckOutTime(dateTimeExit));
        }
        public void CheckOut()
        {
            int id                 = 1;
            int idAlien            = 1;
            int idBallad           = 1;
            int?idObjectNotAllowed = null;

            var checkInCheckOut = new CheckInCheckOut(id, idAlien, idBallad, idObjectNotAllowed);

            checkInCheckOut.CheckOut();

            Assert.True(checkInCheckOut.DateTimeExit != null);
        }
        public void Valid_Constructor()
        {
            int id                 = 1;
            int idAlien            = 1;
            int idBallad           = 1;
            int idObjectNotAllowed = 1;

            var checkInCheckOut = new CheckInCheckOut(id, idAlien, idBallad, idObjectNotAllowed);

            Assert.Equal(id, checkInCheckOut.Id);
            Assert.Equal(id, checkInCheckOut.IdAlien);
            Assert.Equal(id, checkInCheckOut.IdBallad);
            Assert.Equal(id, checkInCheckOut.IdObjectNotAllowed);
        }
        public void CheckIn()
        {
            int id                 = 1;
            int idAlien            = 1;
            int idBallad           = 1;
            int?idObjectNotAllowed = null;
            var now                = DateTime.Now;

            var checkinCheckOut = new CheckInCheckOut(id, idAlien, idBallad, idObjectNotAllowed);

            checkinCheckOut.CheckIn();

            Assert.True(checkinCheckOut.DateTimeEntry > now);
        }
Beispiel #7
0
        public ActionResult CheckInCheckOut(FormCollection collection)
        {
            //HospitalLocation Location = new HospitalLocation();
            //collection
            //return View();
            CheckInCheckOut location = new CheckInCheckOut();

            location.HospitalId = Convert.ToInt32(collection["hospital_name_hid_name"]);
            location.LocationId = 0;



            return(View());
        }
        public IActionResult PostCheckin([FromBody] CheckInCheckOut checkInCheckOut)
        {
            try
            {
                var alien = _context.Aliens.SingleOrDefault(e => e.Id == checkInCheckOut.IdAlien);
                if (alien is null)
                {
                    return(BadRequest("Alien não indentificado"));
                }

                var ballad = _context.Ballads.SingleOrDefault(e => e.Id == checkInCheckOut.IdBallad);
                if (ballad is null)
                {
                    return(BadRequest("Balada não indentificado"));
                }

                if (checkInCheckOut.IdObjectNotAllowed is not null)
                {
                    var objectNotAllowed = _context.ObjectNotAllowed.SingleOrDefault(e => e.Id == checkInCheckOut.IdObjectNotAllowed);
                    if (objectNotAllowed is null)
                    {
                        return(BadRequest("Objeto proibido não indentificado"));
                    }
                }

                if (!alien.AgeCheckMinimumAllowed())
                {
                    return(BadRequest("Idade minima para entrada não permitida"));
                }

                var CheckOut = _context.CheckInCheckOuts.SingleOrDefault(e => e.IdAlien == checkInCheckOut.IdAlien && e.DateTimeExit == null);
                if (CheckOut is not null)
                {
                    return(BadRequest("Alien já está em outra balada"));
                }

                checkInCheckOut.CheckIn();
                _context.CheckInCheckOuts.Add(checkInCheckOut);
                _context.SaveChanges();
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }


            return(Ok());
        }
 public void AddCheckIn(CheckInCheckOut CheckInCheckOut)
 {
     checkInCheckOut.Add(CheckInCheckOut);
     SaveChanges();
 }
 public void Update(CheckInCheckOut Objeto)
 {
     myContext.Update(Objeto);
 }
 public void Delete(CheckInCheckOut Objeto)
 {
     myContext.Delete(Objeto);
 }
 public void Add(CheckInCheckOut Objeto)
 {
     myContext.Add(Objeto);
 }