Exemple #1
0
        public CarServiceType InsertServiceType(CarServiceType carServicetype)
        {
            var insertCar = _sparkDbContext.CarServiceTypes.Add(carServicetype);

            _sparkDbContext.SaveChanges();
            return(carServicetype);
        }
Exemple #2
0
        public CarServiceType EditServiceType(int id, CarServiceType carServiceType)
        {
            var servicetype = _sparkDbContext.CarServiceTypes.Where(e => e.Id == carServiceType.Id).FirstOrDefault();

            servicetype.Name  = carServiceType.Name;
            servicetype.Price = carServiceType.Price;
            _sparkDbContext.SaveChanges();
            return(servicetype);
        }
Exemple #3
0
        public async Task <IActionResult> DeleteServiceType(int id)
        {
            var results = new CarServiceType();

            using (HttpClient client = new HttpClient())
            {
                using (var response = await client.DeleteAsync($"{apiUrl}/{id}"))
                {
                    var apiResponse = await response.Content.ReadAsStringAsync();

                    results = JsonConvert.DeserializeObject <CarServiceType>(apiResponse);
                }
            }
            return(RedirectToAction("GetServiceType"));
        }
Exemple #4
0
        public async Task <IActionResult> Create(CarServiceType carServiceType)
        {
            var resService = new CarServiceType();

            using (var client = new HttpClient())
            {
                var content = new StringContent(JsonConvert.SerializeObject(carServiceType), Encoding.UTF8, "application/json");
                using (var response = await client.PostAsync(apiUrl, content))
                {
                    var apiResponse = await response.Content.ReadAsStringAsync();

                    resService = JsonConvert.DeserializeObject <CarServiceType>(apiResponse);
                }
            }
            return(RedirectToAction("GetServiceType"));
        }
Exemple #5
0
        public async Task <IActionResult> EditServiceType(int id)
        {
            var carService = new CarServiceType();

            using (HttpClient client = new HttpClient())
            {
                //using (var response = await client.GetAsync("https://localhost:44330/api/Character"))
                using (var response = await client.GetAsync($"{apiUrl}/{id}"))
                {
                    var apiResponse = await response.Content.ReadAsStringAsync();

                    carService = JsonConvert.DeserializeObject <CarServiceType>(apiResponse);
                }
            }
            return(View(carService));
        }
Exemple #6
0
        public async Task <IActionResult> EditServiceType(int id, CarServiceType carServ)
        {
            var rescharacter = new CarServiceType();

            using (var client = new HttpClient())
            {
                var content = new StringContent(JsonConvert.SerializeObject(carServ), Encoding.UTF8,
                                                "application/json");
                using (var response = await client.PutAsync($"{apiUrl}/{id}", content))
                {
                    var apiResponse = await response.Content.ReadAsStringAsync();

                    rescharacter = JsonConvert.DeserializeObject <CarServiceType>(apiResponse);
                }
            }
            return(RedirectToAction("GetServiceType"));
        }
Exemple #7
0
        public async Task <IActionResult> GetServiceTypeById(int id)
        {
            var results = new CarServiceType();

            using (HttpClient client = new HttpClient())
            {
                using (var response = await client.GetAsync($"{apiUrl}/{id}"))
                {
                    if (response.StatusCode == HttpStatusCode.OK)
                    {
                        var apiResponse = await response.Content.ReadAsStringAsync();

                        results = JsonConvert.DeserializeObject <CarServiceType>(apiResponse);
                    }
                    else
                    {
                        var noResponse = response.StatusCode.ToString();
                        return(View(noResponse));
                    }
                }
            }
            return(View(results));
        }
Exemple #8
0
        public IActionResult InsertServiceType(CarServiceType carServiceType)
        {
            var insert = _serviceTypeRepository.InsertServiceType(carServiceType);

            return(Ok(insert));
        }
Exemple #9
0
        public IActionResult UpdateServiceType(int id, CarServiceType carServiceType)
        {
            var resUpdate = _serviceTypeRepository.EditServiceType(id, carServiceType);

            return(Ok(resUpdate));
        }