Esempio n. 1
0
 public IActionResult Post([FromBody] ServiceMv Service)
 {
     try
     {
         new ServiceDao(_unitOfWork, _mapper).Create(Service);
         return(Ok());
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         return(NotFound());
     }
 }
 public async Task <ActionResult> UpdateService(ServiceMv Service)
 {
     if (ModelState.IsValid)
     {
         await new ServiceDao().Update(Service);
         var value = await new ServiceDao().GeList();
         return(RedirectToAction("Services", value));
     }
     else
     {
         var data = await new ServiceDao().GetById(Service.Id);
         var list = await new CategoryServiceDao().GeList();
         ViewBag.listCategoryService = list;
         return(View(data));
     }
 }
 public async Task <IActionResult> CreateServices(ServiceMv Service)
 {
     if (ModelState.IsValid)
     {
         var data = await new ServiceDao().CreateServices(Service);
         ViewBag.listCategoryService = data;
         var list = await new ServiceDao().GeList();
         return(View("Services", list));
     }
     else
     {
         var data = await new CategoryServiceDao().GeList();
         ViewBag.listCategoryService = data;
         return(View());
     }
 }
Esempio n. 4
0
        public void Update(ServiceMv service)
        {
            var data = new Service()
            {
                Name              = service.Name,
                Description       = service.Description,
                CategoryServiceId = service.CategoryServiceId,
                Status            = service.Status
            };

            try
            {
                _unitOfWork.Services.Update(data);
                _unitOfWork.Commit();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }
Esempio n. 5
0
        public void Create(ServiceMv service)
        {
            var data = new Service()
            {
                Name              = service.Name,
                Description       = service.Description,
                Price             = service.Price,
                CategoryServiceId = service.CategoryServiceId
            };

            try
            {
                _unitOfWork.Services.Insert(data);
                _unitOfWork.Commit();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }
Esempio n. 6
0
        public async Task <ServiceMv> GetById(int id)
        {
            var data = new ServiceMv();
            var res  = await _api.GetDataById(url, id);

            try
            {
                if (res.IsSuccessStatusCode)
                {
                    var result = res.Content.ReadAsStringAsync().Result;
                    data = JsonConvert.DeserializeObject <ServiceMv>(result);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }

            return(data);
        }
Esempio n. 7
0
        public async Task <HttpResponseMessage> Update(ServiceMv Service)
        {
            var update = await _api.Update <ServiceMv>(url, Service.Id, Service);

            return(update);
        }
Esempio n. 8
0
        public async Task <object> CreateServices(ServiceMv Service)
        {
            var postTask = await _api.PostData <ServiceMv>(url, Service);

            return(postTask);
        }