Exemplo 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());
     }
 }
Exemplo n.º 2
0
 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));
     }
 }
Exemplo n.º 3
0
 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());
     }
 }
Exemplo 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;
            }
        }
Exemplo 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;
            }
        }
Exemplo 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);
        }
Exemplo n.º 7
0
        public async Task <HttpResponseMessage> Update(ServiceMv Service)
        {
            var update = await _api.Update <ServiceMv>(url, Service.Id, Service);

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

            return(postTask);
        }