Ejemplo n.º 1
0
        public async Task <RentalShop> UpdateRentalShop(RentalShop ShopChanges)
        {
            var Shop = context.Shops.Attach(ShopChanges);

            Shop.State = Microsoft.EntityFrameworkCore.EntityState.Modified;
            context.SaveChanges();
            return(await context.Shops.FindAsync(ShopChanges.ID));
        }
Ejemplo n.º 2
0
        //Rental Shops

        public async Task <RentalShop> AddRentalShop(RentalShop rentalShop)
        {
            context.Shops.Add(rentalShop);
            await context.SaveChangesAsync();

            var RentalShop = await context.Shops.OrderByDescending(s => s.ID).FirstOrDefaultAsync();

            return(RentalShop);
        }
Ejemplo n.º 3
0
        public async Task <bool> AddRentalShop(RentalShop rentalShop)
        {
            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri(BaseURL);
                HttpResponseMessage res = await client.PostAsJsonAsync("api/RentalShops", rentalShop);

                return(res.IsSuccessStatusCode);
            }
        }
Ejemplo n.º 4
0
        public async Task <bool> UpdateRentalShop(RentalShop ShopChanges)
        {
            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri(BaseURL);
                HttpResponseMessage res = await client.PutAsJsonAsync($"api/RentalShops/UpdateRentalShop/{ShopChanges.ID}", ShopChanges);

                return(res.IsSuccessStatusCode);
            }
        }
        public async Task <ActionResult> Create(RentalShop rentalShop)
        {
            bool added = await Repository.AddRentalShop(rentalShop);

            if (added == false)
            {
                return(View());
            }

            return(RedirectToAction("Index"));
        }
        public async Task <ActionResult <RentalShop> > PutRentalShop(int id, RentalShop rentalShop)
        {
            if (id != rentalShop.ID)
            {
                return(BadRequest());
            }
            if (!Repository.RentalShopExists(id))
            {
                return(NoContent());
            }

            return(await Repository.UpdateRentalShop(rentalShop));
        }
Ejemplo n.º 7
0
        public async Task <RentalShop> GetRentalShopByID(int id)
        {
            RentalShop rentalShop = new RentalShop();

            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri(BaseURL);
                client.DefaultRequestHeaders.Clear();
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                HttpResponseMessage res = await client.GetAsync($"api/RentalShops/GetRentalShopByID/{id}");

                if (res.IsSuccessStatusCode)
                {
                    var response = res.Content.ReadAsStringAsync().Result;

                    rentalShop = JsonConvert.DeserializeObject <RentalShop>(response);
                }
            }
            return(rentalShop);
        }
 public async Task <ActionResult <RentalShop> > PostRentalShop(RentalShop rentalShop)
 {
     return(await Repository.AddRentalShop(rentalShop));
 }
        public async Task <ActionResult> Details(int id)
        {
            RentalShop rentalShop = await Repository.GetRentalShopByID(id);

            return(View(rentalShop));
        }
        public async Task <ActionResult> Edit(RentalShop rentalShop)
        {
            await Repository.UpdateRentalShop(rentalShop);

            return(RedirectToAction("Index"));
        }
        public IActionResult Create()
        {
            RentalShop rentalShop = new RentalShop();

            return(View(rentalShop));
        }