public ActionResult PostNewParking(string name, string licenseNumber, string phone, string ticketType,
                                           string carType, string height, string width, string length)
        {
            var answer             = "";
            CheckinViewModel model = new CheckinViewModel
            {
                Name = name,
                LicensePlateNumber = licenseNumber,
                Phone      = phone,
                TicketType = ticketType,
                CarType    = carType,
                Height     = height,
                Width      = width,
                Length     = length
            };

            if (_parkingService.CheckValidationOfRequest(model))
            {
                answer = _parkingService.AddVehicleToParking(model);
                return(Ok(new { message = answer }));
            }
            else
            {
                //store the data about the availble tickets
                var           listOfAvailbleTicketes = _parkingService.CheckAvailbleTicketTypes(model);
                StringBuilder sb = new StringBuilder("Dimension not valid, ");
                foreach (var availbleTicket in listOfAvailbleTicketes)
                {
                    sb.Append("Availble ticket: " + availbleTicket.TicketTypeName + "- Cost difference is " + availbleTicket.CostDifference + "$" + Environment.NewLine);
                }
                answer = sb.ToString();
                return(Ok(new { message = answer }));
            }
        }
Exemple #2
0
        public List <AvailbleTicketModel> CheckAvailbleTicketTypes(CheckinViewModel model)
        {
            List <ParkingTicket>       availableTicketList = new List <ParkingTicket>();
            List <AvailbleTicketModel> answer = new List <AvailbleTicketModel>();

            try
            {
                var height = Convert.ToDouble(model.Height);
                var width  = Convert.ToDouble(model.Width);
                var length = Convert.ToDouble(model.Length);

                availableTicketList = AvailableTicketTypes(height, width, length);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.StackTrace);
            }

            var ticket = GetTicketTypeByString(model.TicketType);

            foreach (var availableTicket in availableTicketList)
            {
                answer.Add(new AvailbleTicketModel
                {
                    TicketTypeName = availableTicket.ToString(),
                    CostDifference = availableTicket.Cost - ticket.Cost
                });
            }

            return(answer);
        }
        private void Calcula(CheckinViewModel obj)
        {
            var value = 0;

            for (var day = obj.dataEntrada.Date; day <= obj.dataSaida.Date; day = day.AddDays(1))
            {
                if (day.DayOfWeek == DayOfWeek.Sunday || day.DayOfWeek == DayOfWeek.Saturday)
                {
                    value += 150;
                    if (obj.adicionalVeiculo)
                    {
                        value += 20;
                    }
                }
                else
                {
                    value += 120;
                    if (obj.adicionalVeiculo)
                    {
                        value += 15;
                    }
                }
            }
            obj.value = value;
        }
 public IActionResult Index()
 {
     _vm = new CheckinViewModel {
         Locations       = CheckinStorage.Instance.Locations,
         PersonLocations = CheckinStorage.Instance.PersonLocations
     };
     return(View(_vm));
 }
Exemple #5
0
        public CheckinClientPage(ListRequest clienteseleccionado)
        {
            // Debug.WriteLine(clienteseleccionado.Titulo);


            InitializeComponent();
            viewmodel      = new CheckinViewModel(clienteseleccionado);
            BindingContext = viewmodel;
        }
        public async Task <IActionResult> Checkout([FromBody] CheckinViewModel input)
        {
            var oldCheckin = await db.Checkins.FirstOrDefaultAsync(c => c.Username == input.acid);

            if (oldCheckin != null)
            {
                var _clearCheckins = db.Stations.Where(s => s.LastCheckin == oldCheckin).ForEachAsync(s => s.LastCheckin = null);
                db.Checkins.Remove(oldCheckin);
                await _clearCheckins;
                await db.SaveChangesAsync();
            }

            return(Ok());
        }
Exemple #7
0
        public string AddVehicleToParking(CheckinViewModel model)
        {
            var answerFromManager = "";
            var ticket            = GetTicketTypeByString(model.TicketType);
            var isNotOcupied      = parking.IsAreaAvailbleToPark(model.TicketType);

            if (isNotOcupied)
            {
                answerFromManager = parking.AddNewVehicleToParkingSpot(model.Name, model.LicensePlateNumber, model.Phone, model.TicketType,
                                                                       model.CarType, model.Height, model.Width, model.Length);
            }

            return(answerFromManager);
        }
Exemple #8
0
        public ActionResult Checkin(Guid id)
        {
            var book   = _context.Books.Find(id);
            var borrow = _context.Users.Where(x => x.BookId == id).FirstOrDefault();

            var check = new CheckinViewModel()
            {
                DateCheckedOut = borrow.DateCheckedOut,
                BookId         = book.Id,
                ISBN           = book.ISBN,
                Phone          = borrow.Phone,
                IsCheckedIn    = book.IsCheckedIn,
                Price          = book.Price
            };

            return(View(check));
        }
Exemple #9
0
 public HttpResponseMessage AddCheckin(CheckinViewModel cvm)
 {
     try
     {
         var checkin = new CheckIn
         {
             Name      = cvm.Name,
             StaffId   = cvm.Id,
             IsChecked = true,
             VendorId  = 1
         };
         _checkinservice.Add(checkin);
         return(Request.CreateResponse(HttpStatusCode.OK, "checked"));
     }
     catch (Exception ex)
     {
         return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message));
     }
 }
Exemple #10
0
        public async Task <ActionResult> Checkin([FromBody] CheckinViewModel model)
        {
            var flight = await _flightRepository.GetAsync(model.FlightId);

            var passenger = new Passenger(model.PassengerName, flight);


            model.Baggages.ForEach(b => {
                passenger.AddBaggage(b.Label, b.Weight);
            });

            var validationResponse = await _bookingService.ValidateAndEndBookingSessionAsync(model.FlightId, model.BookingSessionId);

            _passengerRepository.Add(passenger);

            await _passengerRepository.UnitOfWork.SaveChangesAsync();

            return(Ok());
        }
        public string Consult2(bool checkin = false)
        {
            var result   = new Checkin().Select(checkin);
            var checkins = new List <CheckinViewModel>();

            while (result.Read())
            {
                var obj = new CheckinViewModel()
                {
                    hospede = new ClientViewModel()
                    {
                        nome = result[0].ToString()
                    },
                    dataEntrada      = Convert.ToDateTime(result[3]),
                    dataSaida        = Convert.ToDateTime(result[4]),
                    adicionalVeiculo = Convert.ToBoolean(result[5])
                };
                Calcula(obj);
                checkins.Add(obj);
            }
            return(JsonConvert.SerializeObject(checkins));
        }
        public async Task <IActionResult> Checkin([Bind("Serial")] CheckinViewModel checkin)
        {
            var InventoryItem = await _context.InventoryItem.SingleOrDefaultAsync(i => i.Serial == checkin.Serial);

            if (InventoryItem == null)
            {
                ModelState.AddModelError("INVALID_SERIAL", "Serial Number does not exist");
            }
            var pendingCheckout = await _context.Checkout.Where(c => c.End == null).SingleOrDefaultAsync(c => c.InventoryItemID == InventoryItem.ID);

            if (pendingCheckout == null)
            {
                ModelState.AddModelError("NOT_CHECKED_OUT", "Item is not checked out");
            }
            if (ModelState.IsValid)
            {
                pendingCheckout.End = DateTime.Now;
                _context.Entry(pendingCheckout).State = EntityState.Modified;
                _context.SaveChangesAsync();
                return(RedirectToAction(nameof(Index)));
            }
            return(View(checkin));
        }
Exemple #13
0
        public bool CheckValidationOfRequest(CheckinViewModel model)
        {
            bool returnValue = false;

            try
            {
                var height = Convert.ToDouble(model.Height);
                var width  = Convert.ToDouble(model.Width);
                var length = Convert.ToDouble(model.Length);

                var ticket = GetTicketTypeByString(model.TicketType);

                if (CheckDimentions(ticket, height, width, length))
                {
                    returnValue = true;
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.StackTrace);
            }

            return(returnValue);
        }
        public HttpResponseMessage AddCheckin(CheckinViewModel cvm)
        {
            try
            {
                var user = User.IsInRole("VENDOR");

                if (user)
                {
                    var checkin = new CheckIn
                    {

                        StaffId = cvm.Id,
                        IsChecked = true,
                        VendorId = int.Parse(User.Identity.GetUserId())
                    };

                    var Day = cvm.Day;
                    var staff = staffservices.GetSingle(cvm.Id);

                    if (staff != null)
                    {

                        switch (Day)
                        {

                            case 2:
                                if (staff.Monday != true)
                                {
                                    staff.Monday = true;
                                }

                                break;
                            case 3:
                                if (staff.Tuesday != true)
                                {
                                    staff.Tuesday = true;
                                }
                                break;
                            case 4:
                                if (staff.Wednesday != true)
                                {
                                    staff.Wednesday = true;
                                }
                                break;
                            case 5:
                                if (staff.Thursday != true)
                                {
                                    staff.Thursday = true;
                                }
                                break;
                            case 6:
                                if (staff.Friday != true)
                                {
                                    staff.Friday = true;
                                }
                                break;
                            default:

                                break;
                        }

                        UpdateStaff(staff);
                    }

                    _checkinservice.Add(checkin);
                }

                return Request.CreateResponse(HttpStatusCode.OK, "checked");

            }
            catch (Exception ex)
            {
                return Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message);
            }

        }
        public async Task <IActionResult> CheckIn([FromBody] CheckinViewModel input)
        {
            DateTime submitTime = DateTime.Now;

            try
            {
                var checkin = new Checkin
                {
                    LastUpdate = submitTime,
                    Username   = input.acid,
                    Display    = input.display
                };

                //// Update checkin table
                // check existing entries with same userID
                var oldCheckin = await db.Checkins.FirstOrDefaultAsync(c => c.Username == input.acid);

                // write checkin to database
                if (oldCheckin != null)
                {
                    // update time
                    oldCheckin.LastUpdate = submitTime;
                    oldCheckin.Display    = input.display;

                    // clear out old station reg
                    await db.Stations.Where(s => s.LastCheckin.ID == oldCheckin.ID).ForEachAsync(s => s.LastCheckin = null);

                    // switch current checkin
                    checkin = oldCheckin;
                }
                else
                {
                    // make new entry
                    db.Checkins.Add(checkin);
                }

                //// Update station
                // update existing entries with same MAC
                var station = await db.Stations.FirstOrDefaultAsync(s => s.PhysicalAddress == input.address);

                if (station != null)
                {
                    // if station exists, set its checkin to this
                    station.LastCheckin = checkin;
                }
                else
                {
                    // create a new blank slate station
                    db.Stations.Add(new Station
                    {
                        PhysicalAddress   = input.address,
                        Location          = "Unknown",
                        StationEquipments = new List <StationEquipment>(),
                        Capacity          = 1,
                        LastCheckin       = checkin
                    });
                }

                // Commit changes
                await db.SaveChangesAsync();
            }
            catch (Exception e)
            {
                return(BadRequest(e.ToString()));
            }

            return(Ok());
        }
 public CheckinPage()
 {
     InitializeComponent();
     viewmodel      = new CheckinViewModel(null);
     BindingContext = viewmodel;
 }
Exemple #17
0
 public Checkin()
 {
     InitializeComponent();
     BindingContext = new CheckinViewModel();
 }