Пример #1
0
        /// <summary>
        /// Execute a check-out add
        /// </summary>
        /// <param name="id">The reservation id</param>
        /// <param name="data">The timestamp of checkout</param>
        /// <returns>Bool : true successful checked-out false : else</returns>
        public bool CheckOut(string id, WorkSpaceDateDTO data)
        {
            //Get target reservation
            var reservation = Read(id);

            //Not checked-in error
            if (reservation.Status != Reservation.Statuses.CHECKIN)
            {
                return(false);
            }
            //Date inside prenotation
            reservation.CheckOut = reservation.CheckOut.Append(data.Date);
            //Switch status to on goind
            reservation.Status = Reservation.Statuses.INCORSO;
            //Return update status
            return(Update(id, reservation).IsAcknowledged);
        }
Пример #2
0
        public IActionResult CheckOut([FromBody] WorkSpaceDateDTO data)
        {
            var rid = (HttpContext.User.Identity as ClaimsIdentity).FindFirst("userId").Value;
            var id  = Service.FindOnGoindReservationIdByWorkSpaceAndUserIds(data.WorkSpaceId, rid);

            if (id == null)
            {
                return(NotFound());
            }
            if (!_acs.IsOwner <ReservationService, Reservation>(rid, id, Service))
            {
                return(Forbid());
            }
            if (Service.CheckOut(id, data))
            {
                return(Ok());
            }
            return(BadRequest());
        }
Пример #3
0
        /// <summary>
        /// Execute a check-in add
        /// </summary>
        /// <param name="id">The reservation id</param>
        /// <param name="data">The timestamp of check-in</param>
        /// <returns>Bool : true successful checked-in false : else</returns>
        public bool CheckIn(string id, WorkSpaceDateDTO data)
        {
            //@TODO use external validator?
            //Not check-in valid status or already checked-in or not running
            var reservation = Read(id);

            if (_storedStatuses.Contains(reservation.Status) ||
                reservation.Status == Reservation.Statuses.CHECKIN ||
                reservation.Status == Reservation.Statuses.ATTIVA
                )
            {
                return(false);
            }

            //Add check-in
            reservation.CheckIn = reservation.CheckIn.Append(data.Date);
            //Switch statis
            reservation.Status = Reservation.Statuses.CHECKIN;
            //Return update result
            return(Update(id, reservation).IsAcknowledged);
        }