public async Task <ActionResult> ServicesDelete(short id, short departmentId)
        {
            try
            {
                var model = new DepartmentServicesViewModel();
                model.Id           = id;
                model.DepartmentId = departmentId;

                //Call API Provider
                string strUrl = APIProvider.APIGenerator("DepartmentServices", APIConstant.ACTION_DELETE);
                var    result = await APIProvider.Authorize_DynamicTransaction <DepartmentServicesViewModel, bool>(model, _userSession.BearerToken, strUrl, APIConstant.API_Resource_CORE, ARS.Delete);

                if (result)
                {
                    TempData["Alert"] = ApplicationGenerator.RenderResult(ApplicationGenerator.TypeResult.SUCCESS, ApplicationGenerator.GeneralActionMessage(APIConstant.ACTION_DELETE, ApplicationGenerator.TypeResult.SUCCESS));
                }
                else
                {
                    TempData["Alert"] = ApplicationGenerator.RenderResult(ApplicationGenerator.TypeResult.FAIL, ApplicationGenerator.GeneralActionMessage(APIConstant.ACTION_DELETE, ApplicationGenerator.TypeResult.FAIL));
                }

                return(RedirectToAction("Services", new { departmentId = departmentId }));
            }
            catch (Exception ex)
            {
                TempData["Alert"] = ApplicationGenerator.RenderResult(ApplicationGenerator.TypeResult.FAIL, ApplicationGenerator.GeneralActionMessage(APIConstant.ACTION_DELETE, ApplicationGenerator.TypeResult.FAIL));
                Logger.LogError(ex);
                return(RedirectToAction("Services", new { departmentId = departmentId }));
            }
        }
 public async Task <ActionResult> ServicesDelete(DepartmentServicesViewModel model)
 {
     if (!await APIProvider.Authorization(_userSession.BearerToken, ARS.Delete))
     {
         TempData["Alert"] = ApplicationGenerator.RenderResult(ApplicationGenerator.FuntionType.Department, APIConstant.ACTION_INSERT);
         return(RedirectToAction("Index"));
     }
     else
     {
         return(PartialView("_ServicesDelete", model));
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Get by Id
        /// </summary>
        /// <param name="id"></param>
        /// <returns>Category view model</returns>
        // GET api/values/5
        public async Task <DepartmentServicesViewModel> GetById(short id, short departmentId)
        {
            IList <string> list = new List <string> {
                "id", "departmentId"
            };
            var para = APIProvider.APIDefaultParameter(list, id, departmentId);

            var source = await _departmentServices.SingleQuery(para);

            DepartmentServicesViewModel dest = Mapper.Map <DepartmentServicesViewModel>(source);

            return(dest);
        }
        public async Task <ActionResult> ServicesCreate(DepartmentServicesViewModel model)
        {
            if (ModelState.IsValid)
            {
                //Call API Provider
                string strUrl = APIProvider.APIGenerator("DepartmentServices", APIConstant.ACTION_INSERT);
                var    result = await APIProvider.Authorize_DynamicTransaction <DepartmentServicesViewModel, bool>(model, _userSession.BearerToken, strUrl, APIConstant.API_Resource_CORE, ARS.Insert);

                if (result)
                {
                    TempData["Alert"] = ApplicationGenerator.RenderResult(ApplicationGenerator.TypeResult.SUCCESS, ApplicationGenerator.GeneralActionMessage(APIConstant.ACTION_INSERT, ApplicationGenerator.TypeResult.SUCCESS));
                }
                else
                {
                    TempData["Alert"] = ApplicationGenerator.RenderResult(ApplicationGenerator.TypeResult.FAIL, ApplicationGenerator.GeneralActionMessage(APIConstant.ACTION_INSERT, ApplicationGenerator.TypeResult.FAIL));
                }
                return(RedirectToAction("Services", new { departmentId = model.DepartmentId }));
            }
            else
            {
                return(View("Index", model));
            }
        }
Ejemplo n.º 5
0
        public async Task <bool> Transaction(DepartmentServicesViewModel model, char action)
        {
            var obj = Mapper.Map <Domain.Models.CORE.DepartmentServices>(model);

            return(await _departmentServices.Transaction(obj, action));
        }