Exemplo n.º 1
0
        public IActionResult DeadActiveDetail([FromBody] CreateEditDetailViewModel model)
        {
            //DataClaim.GetClaim(Request);
            if (model == null)
            {
                return(BadRequest("Organization Unit Change Detail is null."));
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }


            var decryptedID = Convert.ToInt32(EncryptionHelper.DecryptUrlParam(model.ID));

            model.ID = decryptedID.ToString();

            var title      = _orgUnitChangeProvider.GetOrgChangeDetail(decryptedID);
            var menuMapper = _mapper.Map(model, title);

            menuMapper.SuperiorId    = Convert.ToInt32(EncryptionHelper.DecryptUrlParam(model.EmployeeID));
            menuMapper.ParentId      = Convert.ToInt32(EncryptionHelper.DecryptUrlParam(model.OrganizationUnitID));
            menuMapper.StatusId      = OrgChangeStatus.NotActive;
            menuMapper.Id            = 0;
            menuMapper.IsCurrentUsed = true;
            //menuMapper.IsActive = false;

            _orgUnitChangeProvider.ChangeIsCurrentUsed(model.OrgUnitID);
            _orgUnitChangeProvider.DeadActiveDetail(menuMapper);
            return(Ok());
        }
Exemplo n.º 2
0
        public IActionResult PostDetail([FromBody] CreateEditDetailViewModel model)
        {
            //DataClaim.GetClaim(Request);
            if (model is null)
            {
                return(BadRequest("Organization Unit Detail Change is null."));
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            OrgUnitTransactionDetail detail = new OrgUnitTransactionDetail();
            var menuMapper = _mapper.Map(model, detail);

            menuMapper.SuperiorId    = Convert.ToInt32(EncryptionHelper.DecryptUrlParam(model.EmployeeID));
            menuMapper.ParentId      = Convert.ToInt32(EncryptionHelper.DecryptUrlParam(model.OrganizationUnitID));
            menuMapper.StatusId      = OrgChangeStatus.Add;
            menuMapper.IsCurrentUsed = true;
            //menuMapper.IsActive = true;

            _orgUnitChangeProvider.AddOrgUnitChangeDetail(menuMapper);
            return(Ok(model));
        }
Exemplo n.º 3
0
        public ActionResult CreateDetail(int orgChangeID)
        {
            var model = new CreateEditDetailViewModel();

            model.OrgUnitTransactionID = orgChangeID;
            model.BeginEff             = DateTime.Today;
            model.StatusID             = 1;
            return(PartialView("CreateEditDetail", model));
        }
Exemplo n.º 4
0
        public ActionResult NonActiveDetail(string id)
        {
            var jsonViewModel = new AjaxViewModel();
            CreateEditDetailViewModel model = new CreateEditDetailViewModel();

            try
            {
                int decryptID = Convert.ToInt32(EncryptionHelper.DecryptUrlParam(id));
                var endpoint  = url + "/GetDetail/" + decryptID;
                model = Utilities.RestAPIHelper <CreateEditDetailViewModel> .Submit("", Method.GET, endpoint);
            }
            catch (Exception ex)
            {
                jsonViewModel.SetValues(false, null, String.Format("Failed\\nMessage: {0}", ex.GetBaseException().Message));
            }
            return(PartialView("CreateEditDetail", model));
        }
Exemplo n.º 5
0
        public IActionResult GetDetail(int id)
        {
            var jobTitle = _orgUnitChangeProvider.GetOrgChangeDetail(id);

            if (jobTitle == null)
            {
                return(NotFound("Organization Unit Change Detail not found."));
            }

            CreateEditDetailViewModel detail = new CreateEditDetailViewModel();
            var menuMapper = _mapper.Map(jobTitle, detail);

            menuMapper.EmployeeID         = EncryptionHelper.EncryptUrlParam(Convert.ToString(jobTitle.SuperiorId));
            menuMapper.EmployeeName       = _orgUnitChangeProvider.GetActiveEmployeeBiodata(Convert.ToInt32(jobTitle.SuperiorId)).NickName;
            menuMapper.OrganizationUnitID = EncryptionHelper.EncryptUrlParam(Convert.ToString(jobTitle.ParentId));
            menuMapper.OrganizationUnit   = jobTitle.ParentId == 0 ? "" : _orgUnitChangeProvider.GetOrgUnit(Convert.ToInt32(jobTitle.ParentId)).Name;
            return(Ok(menuMapper));
        }
Exemplo n.º 6
0
        public ActionResult NonActiveDetail(CreateEditDetailViewModel model)
        {
            var jsonViewModel = new AjaxViewModel();

            try
            {
                string json = JsonConvert.SerializeObject(model);

                var endpoint = url + "/DeadActiveDetail";
                model = Utilities.RestAPIHelper <CreateEditDetailViewModel> .Submit(json, Method.PUT, endpoint);

                jsonViewModel.SetValues(true, null, "Saved");
            }
            catch (Exception ex)
            {
                jsonViewModel.SetValues(false, null, String.Format("Failed\\nMessage: {0}", ex.GetBaseException().Message));
            }
            return(Json(jsonViewModel));
        }
        public AjaxViewModel ValidateOrgUnitChangeDetail(CreateEditDetailViewModel model)
        {
            AjaxViewModel viewModel = new AjaxViewModel();

            var id          = Convert.ToInt32(model.ID);
            var existedCode = GetOrgChangeDetail().Any(jt =>
                                                       jt.Code == model.Code.ToLower() &&
                                                       jt.Id != id &&
                                                       !jt.DelDate.HasValue &&
                                                       jt.BusinessGroupId == businessGroupID);

            if (existedCode)
            {
                viewModel.IsSuccess = false;
                viewModel.Message   = "Code has been used";
            }
            else
            {
                viewModel.IsSuccess = true;
                viewModel.Message   = "Success";
            }
            return(viewModel);
        }