예제 #1
0
        public ActionResult Add()
        {
            var streamReader   = new StreamReader(_context.Request.InputStream);
            var jsonSerializer = new JsonSerializer();
            var bookingModel   = jsonSerializer.Deserialize <BookingModel>(new JsonTextReader(streamReader));

            if (
                _schedulePersistence.GetAll()
                .All(
                    schedule =>
                    string.Compare(schedule.ID, bookingModel.ScheduleID,
                                   StringComparison.InvariantCultureIgnoreCase) !=
                    0))
            {
                return(Error());
            }

            if (
                _userPersistence.GetAll()
                .All(
                    user =>
                    string.Compare(user.ID, bookingModel.UserID, StringComparison.InvariantCultureIgnoreCase) !=
                    0))
            {
                return(Error());
            }

            if (_bookingPersistence.Add(bookingModel) == PersistenceCodes.IdAlreadyUsed)
            {
                return(Error());
            }

            return(Json(bookingModel));
        }
예제 #2
0
        public ActionResult GetAll()
        {
            var allMovies = _schedulePersistence.GetAll();

            return(Json(allMovies));
        }