Example #1
0
        public HttpResponseMessage Get(string tenant_id)
        {
            List <BanqueContainer> nulledbanks = new List <BanqueContainer>();

            var Banques = BanqueService.GetAll().Where(o => o.Owner == tenant_id);

            if (Banques == null)
            {
                return(Request.CreateResponse(HttpStatusCode.NotFound, "No content or wrong tenant id"));
            }

            else
            {
                foreach (Banque b in Banques)
                {
                    BanqueContainer bc = new BanqueContainer();
                    bc.ID          = b.ID;
                    bc.BanqueName  = b.BanqueName;
                    bc.Description = b.Description;
                    nulledbanks.Add(bc);
                }

                return(Request.CreateResponse(HttpStatusCode.OK, nulledbanks));
            }
        }
Example #2
0
        // GET: /Banque/5?tenant-id
        public HttpResponseMessage Get(string tenant_id, int id)
        {
            Banque b = BanqueService.GetById(id);

            if (b == null)
            {
                return(Request.CreateResponse(HttpStatusCode.NotFound, "Incorrect bank id"));
            }

            else if (b.Owner != tenant_id)
            {
                return(Request.CreateResponse(HttpStatusCode.Forbidden, "You are not allowed, check your tenant id"));
            }

            else
            {
                BanqueContainer bc = new BanqueContainer();
                bc.ID          = b.ID;
                bc.BanqueName  = b.BanqueName;
                bc.Description = b.Description;

                return(Request.CreateResponse(HttpStatusCode.OK, bc));
            }
        }