Exemplo n.º 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));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Lista todos os usuarios do sistema
        /// </summary>
        /// <returns>Uma lista de usuarios</returns>
        public IList <User> GetAll()
        {
            UserPersistence userPersistence = new UserPersistence();

            return(userPersistence.GetAll <User>());
        }
Exemplo n.º 3
0
        public ActionResult GetAll()
        {
            var allUsers = _userPersistence.GetAll();

            return(Json(allUsers));
        }
Exemplo n.º 4
0
 public List <User> GetAll() => userPersistence.GetAll();