Beispiel #1
0
        public IActionResult EditGradeDetail([FromBody] CreateEditGradeDetailViewModel model)
        {
            if (model == null)
            {
                return(BadRequest(" Grade is null."));
            }
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }
            var decryptedID = Convert.ToInt32(EncryptionHelper.DecryptUrlParam(model.ID));

            model.ID = decryptedID.ToString();
            var grade = _groupGradeProvider.GetGradeDetail(Convert.ToInt32(model.ID));
            //int headerID = grade.GroupGradeId;
            //int sequenceLevelBefore = (int)grade.Sequence;
            //int sequenceLevelNow = model.Sequence;
            //_groupGradeProvider.UpdateSequenceLevel(sequenceLevelBefore, sequenceLevelNow, headerID);

            var gradeMapper = _mapper.Map(model, grade);

            _groupGradeProvider.EditGradeDetail(gradeMapper);


            return(Ok());
        }
        public ActionResult EditGradeDetail(CreateEditGradeDetailViewModel model)
        {
            var jsonViewModel = new AjaxViewModel();

            try
            {
                string json     = JsonConvert.SerializeObject(model);
                var    endpoint = String.Format("{0}/ValidateGrade", url);
                var    isValid  = Utilities.RestAPIHelper <AjaxViewModel> .Submit(json, Method.POST, endpoint, Request);

                if (!isValid.IsSuccess)
                {
                    jsonViewModel.SetValues(isValid.IsSuccess, null, isValid.Message);
                }
                else
                {
                    endpoint = String.Format("{0}/EditGradeDetail", url);

                    model = Utilities.RestAPIHelper <CreateEditGradeDetailViewModel>
                            .Submit(json, Method.PUT, endpoint, Request);

                    jsonViewModel.SetValues(true, null, "Saved");
                }
            }
            catch (Exception ex)
            {
                jsonViewModel.SetValues(false, null, String.Format("Failed\\nMessage: {0}", ex.GetBaseException().Message));
            }
            return(Json(jsonViewModel));
        }
        public ActionResult EditGradeDetail(string id)
        {
            var jsonViewModel = new AjaxViewModel();
            CreateEditGradeDetailViewModel model = new CreateEditGradeDetailViewModel();

            try
            {
                int decryptID = Convert.ToInt32(EncryptionHelper.DecryptUrlParam(id));
                var endpoint  = String.Format("{0}/GetGradeDetail/{1}", url, decryptID);

                model = Utilities.RestAPIHelper <CreateEditGradeDetailViewModel>
                        .Submit("", Method.GET, endpoint, Request);

                string encryptID = EncryptionHelper.EncryptUrlParam(model.GroupGradeID);

                var maxSequence = String.Format("{0}/MaxSequenceLevel/{1}", url, encryptID);

                model.MaxSequence = Utilities.RestAPIHelper <int>
                                    .Submit("", Method.GET, maxSequence, Request);
            }
            catch (Exception ex)
            {
                jsonViewModel.SetValues(false, null, String.Format("Failed\\nMessage: {0}", ex.GetBaseException().Message));
            }
            return(PartialView("CreateEditGradeDetail", model));
        }
Beispiel #4
0
        public IActionResult MaxSequenceByGroupGradeId(string groupGradeID)
        {
            var model     = new CreateEditGradeDetailViewModel();
            int decryptID = Convert.ToInt32(EncryptionHelper.DecryptUrlParam(groupGradeID));

            model.MaxSequence = _groupGradeProvider.MaxSequenceByGroupGradeId(decryptID);
            return(Ok(model.MaxSequence));
        }
Beispiel #5
0
        public IActionResult ValidateCombinationGrade([FromBody] CreateEditGradeDetailViewModel model)
        {
            //model.GroupGradeID = EncryptionHelper.DecryptUrlParam(model.GroupGradeID);
            //int headerID = Int32.Parse(model.GroupGradeID);
            model.ID = (model.ID == null || model.ID == "" ? "0" : EncryptionHelper.DecryptUrlParam(model.ID));
            var isValid = _groupGradeProvider.validateCombinationGrade(model);

            //var isValid = _groupGradeProvider.validateCombinationGrade(model, headerID);

            return(Ok(isValid));
        }
        public ActionResult CreateGradeDetail(string headerID)
        {
            var model = new CreateEditGradeDetailViewModel();

            model.GroupGradeID = headerID;

            var endpoint = String.Format("{0}/MaxSequenceLevel/{1}", url, headerID);

            model.MaxSequence = Utilities.RestAPIHelper <int>
                                .Submit("", Method.GET, endpoint, Request);

            return(PartialView("CreateEditGradeDetail", model));
        }
Beispiel #7
0
        public IActionResult AddGradeDetail([FromBody] CreateEditGradeDetailViewModel grade)
        {
            var model = new Grade();

            if (grade is null)
            {
                return(BadRequest("Grade is null."));
            }
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }
            grade.GroupGradeID = EncryptionHelper.DecryptUrlParam(grade.GroupGradeID);
            int headerID = Int32.Parse(grade.GroupGradeID);
            //int sequenceLevelBefore = _groupGradeProvider.MaxSequenceByGroupGradeId(headerID) + 1;
            //int sequenceLevelNow = grade.Sequence;
            //_groupGradeProvider.UpdateSequenceLevel(sequenceLevelBefore, sequenceLevelNow,headerID);

            var gradeMapper = _mapper.Map(grade, model);

            _groupGradeProvider.AddGradeDetail(gradeMapper);
            return(Ok(grade));
        }
        public AjaxViewModel validateCombinationGrade(CreateEditGradeDetailViewModel model)
        {
            AjaxViewModel viewModel = new AjaxViewModel();

            var id          = Convert.ToInt32(model.ID);
            var existedCode = context.Grade.Any(gr =>
                                                gr.Code.ToLower() == model.Code.ToLower() &&
                                                (gr.Id != id)
                                                //&&(gr.GroupGradeId == groupGradeID)
                                                && !gr.DelDate.HasValue &&
                                                gr.BusinessGroupId == businessGroupID);

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