/// <summary>
        /// Swap order index of Object
        /// </summary>
        /// <param name="swapId"></param>
        /// <returns></returns>
        public async Task <WorkHistoryViewModel> UpdateOrderIndexWorkHistory(SwapOrderIndexRequestModel swapId)
        {
            model.AppResult.Result = false;
            var tempCurrentWorkHistoryInfo = await _workHistoryRepository.FindAsync(swapId.CurrentId);

            var tempTurnedWorkHistoryInfo = await _workHistoryRepository.FindAsync(swapId.TurnedId);

            if (tempCurrentWorkHistoryInfo is null || tempTurnedWorkHistoryInfo is null)
            {
                model.AppResult.Message = Constant.WORKHISTORY_ERROR;
                return(model);
            }

            int tempOrderIndex = -1;

            tempOrderIndex = tempCurrentWorkHistoryInfo.OrderIndex;
            tempCurrentWorkHistoryInfo.OrderIndex = tempTurnedWorkHistoryInfo.OrderIndex;
            tempTurnedWorkHistoryInfo.OrderIndex  = tempOrderIndex;

            tempTurnedWorkHistoryInfo.UpdatedAt  = DateTime.Now;
            tempCurrentWorkHistoryInfo.UpdatedAt = DateTime.Now;

            var tempCurrent = await _workHistoryRepository.UpdateAsync(tempCurrentWorkHistoryInfo);

            var tempTurned = await _workHistoryRepository.UpdateAsync(tempTurnedWorkHistoryInfo);

            if (tempCurrent > 0 && tempTurned > 0)
            {
                model.AppResult.Message = Constant.SWAP_SUCCESS;
                model.AppResult.Result  = true;
                return(model);
            }
            model.AppResult.Message = Constant.SWAP_ERROR;
            return(model);
        }
        public async Task <IActionResult> SwapOrderIndex([FromBody] SwapOrderIndexRequestModel swapId)
        {
            var tempEducationModel = await _educationService.UpdateOrderIndexEducation(swapId);

            if (!tempEducationModel.AppResult.Result)
            {
                return(BadRequest(tempEducationModel.AppResult));
            }
            return(Ok(tempEducationModel.AppResult));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> SwapOrderIndex([FromBody] SwapOrderIndexRequestModel swapId)
        {
            var result = await _workHistoryService.UpdateOrderIndexWorkHistory(swapId);

            if (!result.AppResult.Result)
            {
                return(BadRequest(result.AppResult));
            }
            return(Ok(result.AppResult));
        }
Exemplo n.º 4
0
        public async Task <IActionResult> SwapOrderIndexProject([FromBody] SwapOrderIndexRequestModel project)
        {
            var app = await _projectService.SwapOderIndexProject(project);

            if (!app.AppResult.Result)
            {
                return(BadRequest(app.AppResult));
            }
            return(Ok(app.AppResult));
        }
Exemplo n.º 5
0
        /// <summary>
        /// Swap OrderIndex
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public async Task <SkillViewModel> SwapOrderIndex(SwapOrderIndexRequestModel modelSwap)
        {
            if (modelSwap.CurrentId > 0 && modelSwap.TurnedId > 0)
            {
                var tempCurrentPersonCategory = await _skillRepository.GetPersonCategoryAsync(modelSwap.CurrentId, null, null);

                var tempTeurnedPersonCategory = await _skillRepository.GetPersonCategoryAsync(modelSwap.TurnedId, null, null);

                if (tempCurrentPersonCategory == null || tempTeurnedPersonCategory == null)
                {
                    model.AppResult.Message = "Swap fail, Skill not exists";
                }
                else
                {
                    int orderIndexCurrentPersonCategory = tempCurrentPersonCategory.OrderIndex;
                    int orderIndexTeurnedPersonCategory = tempTeurnedPersonCategory.OrderIndex;
                    tempCurrentPersonCategory.OrderIndex = orderIndexTeurnedPersonCategory;
                    tempCurrentPersonCategory.UpdatedAt  = DateTime.Now;
                    tempCurrentPersonCategory.UpdatedBy  = WebAPI.Helpers.HttpContext.CurrentUser;
                    tempTeurnedPersonCategory.OrderIndex = orderIndexCurrentPersonCategory;
                    tempTeurnedPersonCategory.UpdatedAt  = DateTime.Now;
                    tempTeurnedPersonCategory.UpdatedBy  = WebAPI.Helpers.HttpContext.CurrentUser;
                    List <PersonCategory> personCategories = new List <PersonCategory>();
                    personCategories.Add(tempCurrentPersonCategory);
                    personCategories.Add(tempTeurnedPersonCategory);
                    var result = await _skillRepository.UpdateOrderIndexPersonCategory(personCategories);

                    model.AppResult = new AppResult {
                        Result = true, StatusCd = "200", Message = "Success"
                    };
                }
            }
            else
            {
                model.AppResult.Message = "Swap fail, Invalid CurrentId or TurnedId";
            }
            return(model);
        }
Exemplo n.º 6
0
        public async Task <ProjectViewModel> SwapOderIndexProject(SwapOrderIndexRequestModel project)
        {
            var CurrentProject = await GetProjectById(project.CurrentId);

            var TurnedProject = await GetProjectById(project.TurnedId);

            if (CurrentProject is null || TurnedProject is null)
            {
                model.AppResult.Result  = false;
                model.AppResult.Message = Constant.SWAP_ERROR;
                return(model);
            }

            CurrentProject.UpdatedBy = HttpContext.CurrentUser;
            CurrentProject.UpdatedAt = DateTime.Now;
            TurnedProject.UpdatedBy  = HttpContext.CurrentUser;
            TurnedProject.UpdatedAt  = DateTime.Now;

            int OrderIndex = -1;

            OrderIndex = CurrentProject.OrderIndex;
            CurrentProject.OrderIndex = TurnedProject.OrderIndex;
            TurnedProject.OrderIndex  = OrderIndex;

            var Current = await UpdateProject(CurrentProject);

            var Turned = await UpdateProject(TurnedProject);


            if (Current.AppResult.Result && Turned.AppResult.Result)
            {
                model.AppResult.Result  = true;
                model.AppResult.Message = Constant.SWAP_SUCCESS;
                return(model);
            }
            return(model);
        }
Exemplo n.º 7
0
        public async Task <CertificateViewModel <SaveCertificateResource> > UpdateOrderIndexCertificate(SwapOrderIndexRequestModel swapId)
        {
            model.AppResult.Result = false;
            var tempCurrentCertificateInfo = await _certificateRepository.FindAsync(swapId.CurrentId);

            var tempTurnedCertificateInfo = await _certificateRepository.FindAsync(swapId.TurnedId);

            if (tempCurrentCertificateInfo is null || tempTurnedCertificateInfo is null)
            {
                model.AppResult.Message = Constant.SWAP_ERROR;
                return(model);
            }

            // Set who edited?
            tempCurrentCertificateInfo.UpdatedBy = Helpers.HttpContext.CurrentUser;
            tempCurrentCertificateInfo.UpdatedAt = DateTime.Now;

            tempTurnedCertificateInfo.UpdatedBy = Helpers.HttpContext.CurrentUser;
            tempTurnedCertificateInfo.UpdatedAt = DateTime.Now;

            // Swap OrderIndex
            int tempOrderIndex = 0;

            tempOrderIndex = tempCurrentCertificateInfo.OrderIndex;
            tempCurrentCertificateInfo.OrderIndex = tempTurnedCertificateInfo.OrderIndex;
            tempTurnedCertificateInfo.OrderIndex  = tempOrderIndex;
            // Execute swap
            var isSuccess = await _certificateRepository.SwapOrderIndexAsync(tempCurrentCertificateInfo, tempTurnedCertificateInfo);

            if (isSuccess)
            {
                model.AppResult.Result  = true;
                model.AppResult.Message = Constant.SWAP_SUCCESS;
                return(model);
            }
            model.AppResult.Message = "Taylor Swift";
            return(model);
        }
Exemplo n.º 8
0
        public async Task <IActionResult> SwapOrderIndex([FromBody] SwapOrderIndexRequestModel model)
        {
            var app = await _skillService.SwapOrderIndex(model);

            return(Ok(app.AppResult));
        }