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

            if (
                _moviePersistence.GetAll()
                .All(
                    movie =>
                    string.Compare(movie.ID, scheduleModel.MovieID, StringComparison.InvariantCultureIgnoreCase) !=
                    0))
            {
                return(Error());
            }

            if (
                _roomPersistence.GetAll()
                .All(
                    room =>
                    string.Compare(room.ID, scheduleModel.RoomID, StringComparison.InvariantCultureIgnoreCase) !=
                    0))
            {
                return(Error());
            }

            if (_schedulePersistence.Add(scheduleModel) == PersistenceCodes.IdAlreadyUsed)
            {
                return(Error());
            }

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

            return(Json(allMovies));
        }