Exemplo n.º 1
0
        public object Put(CafeRequest request)
        {
            DbCafe dbCafe = new DbCafe();

            if (request.Id.HasValue)
            {
                var cafe = new Cafe
                {
                    Id          = request.Id.Value,
                    Name        = request.Name,
                    Zip         = request.Zip,
                    Address     = request.Address,
                    OpenTime    = request.OpenTime,
                    CloseTime   = request.CloseTime,
                    Type        = request.Type,
                    PhoneNo     = request.PhoneNo,
                    Description = request.Description
                };
                dbCafe.UpdateCafe(cafe);
                var upCafe = dbCafe.GetCafeById(cafe.Id);
                return(new CafeResponse
                {
                    Result = new Cafe[] { upCafe }
                });
            }
            else
            {
                throw new Exception("Please enter a vaild ID on the cafe!");
            }
        }
Exemplo n.º 2
0
        public object Get(CafeRequest request)
        {
            DbCafe dbCafe = new DbCafe();

            if (request.Id.Value == -1)
            {
                return(new CafeResponse {
                    Result = dbCafe.GetAllCafes()
                });
            }
            else
            {
                var cafe = dbCafe.GetCafeById(request.Id.Value);
                return(new CafeResponse
                {
                    Result = new Cafe[] { cafe }
                });
            }
        }