Пример #1
0
        public async Task <bool> AcceptBusinessReq(AcceptBusinessRequirement accept)
        {
            try
            {
                var secIds = await GetListOfAllSectionsAsync(accept);

                var azimuthProcess = new List <int>();
                await GetAllAzimuthProcessBySectionIdAsync(accept.SectionId, azimuthProcess);

                var companyProcessId = await GetCompanyProcessByAzimuthProcess(azimuthProcess);

                foreach (var item in azimuthProcess)
                {
                    await UpdateLawProcess(accept, secIds, item);
                }

                foreach (var item in secIds)
                {
                    await AcceptSectionOfLaw(accept, companyProcessId, item);
                }
                return(true);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.ToString());
            }
        }
Пример #2
0
        public async Task <IHttpActionResult> PostAcceptBusinessRequirement(AcceptBusinessRequirement accept)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest("Invalid parameters"));
            }

            Respose <bool> respose = new Respose <bool>();

            try
            {
                //var hasRequirements = await _checkDataService.CheckRequirements(accept);
                //var isProcessMapped = await _checkDataService.CheckProcessMapping(accept);
                //if (!hasRequirements)
                //{
                //    ConflictResponseRequirement(accept, respose);
                //    return new NegotiatedContentResult<Respose<bool>>(HttpStatusCode.Conflict, respose, this);
                //}

                //if (!isProcessMapped)
                //{
                //    ConflictResponseProcessMapping(accept, respose);
                //    return new NegotiatedContentResult<Respose<bool>>(HttpStatusCode.Conflict, respose, this);
                //}
                accept.UserId   = UserId;
                accept.UserName = UserName;
                var result = await _lawAcceptanceService.AcceptBusinessRequirement(accept);

                if (result)
                {
                    LawAcceptanceSuccessResponse(respose);
                    return(new NegotiatedContentResult <Respose <bool> >(HttpStatusCode.OK, respose, this));
                }
                else
                {
                    LawAcceptanceFailureResponse(respose);
                    return(new NegotiatedContentResult <Respose <bool> >(HttpStatusCode.ExpectationFailed, respose, this));
                }
            }
            catch (Exception)
            {
                return(InternalServerError());
            }
        }
Пример #3
0
        private async Task AcceptSectionOfLaw(AcceptBusinessRequirement accept, IEnumerable <int> companyProcessId, int sectionId)
        {
            foreach (var item in companyProcessId)
            {
                var chkexst = await CheckExistanceInLawStatusBusinessModule(sectionId, item);

                if (!chkexst)
                {
                    AcceptParams acceptParams = new AcceptParams
                    {
                        SectionId        = sectionId,
                        CreatedBy        = accept.UserName,
                        LawDetailId      = accept.LawDetailId,
                        CompanyProcessId = item,
                        Flag             = (int)accept.Flag,
                        UserId           = accept.UserId
                    };
                    await AcceptLaw(acceptParams);
                }
            }
        }
Пример #4
0
        private async Task <List <int> > GetListOfAllSectionsAsync(AcceptBusinessRequirement accept)
        {
            var parentSection = await connection.QueryAsync <int>(QueryConstants.GET_PARENT_OF_MAPPED, new
            {
                sectionId = new List <int>()
                {
                    accept.SectionId
                }
            }).ConfigureAwait(false);

            var secIds = new List <int>();

            if (parentSection.FirstOrDefault() > 0)
            {
                secIds = await AllMappedSectionId(parentSection.FirstOrDefault());
            }

            if (secIds != null && secIds.Count() != 0)
            {
                parentSection = await connection.QueryAsync <int>(QueryConstants.GET_PARENT_OF_MAPPED, new
                {
                    sectionId = secIds
                }).ConfigureAwait(false);

                if (parentSection.Count() == 1)
                {
                    accept.SectionId = parentSection.FirstOrDefault();
                }
            }

            else
            {
                secIds = new List <int>
                {
                    accept.SectionId
                };
            }

            return(secIds);
        }
Пример #5
0
        private async Task UpdateLawProcess(AcceptBusinessRequirement accept, List <int> secIds, int item)
        {
            var azProcess = new List <int> {
                item
            };

            var companyProcessId1 = GetCompanyProcessByAzimuthProcess(azProcess);

            var companyProcesses = string.Join(",", companyProcessId1);

            UpdateParams updateParams = new UpdateParams
            {
                AzimuthProcessId = item,
                CompanyProcessId = companyProcesses,
                Flag             = (int)accept.Flag,
                SectionId        = secIds,
                LawDetailId      = accept.LawDetailId,
                UserId           = accept.UserId,
                ModifiedBy       = accept.UserName
            };

            await UpdateLawProcesses(updateParams);
        }
Пример #6
0
 private void ConflictResponseRequirement(AcceptBusinessRequirement acceptBusinessReqs, Respose <bool> respose)
 {
     respose.Result  = false;
     respose.Message = "Selected law does not have any requirement.";
 }
Пример #7
0
 private void ConflictResponseProcessMapping(AcceptBusinessRequirement acceptBusinessReqs, Respose <bool> respose)
 {
     respose.Result  = false;
     respose.Message = "No process mapped. Contact system administrator.";
 }
Пример #8
0
        public async Task <bool> AcceptBusinessRequirement(AcceptBusinessRequirement accept)
        {
            var result = await _lawAcceptanceRepository.AcceptBusinessReq(accept);

            return(result);
        }