コード例 #1
0
        public async Task <ActionResult <OrgVm> > GetRoots()
        {
            try
            {
                if (!_cache.TryGetValue(CacheKeys.EnterpriseContact_GetRoots, out OrgVm data))
                {
                    var departments = await _departmentAppService.GetRootListAsync();

                    var employees = await _employeeAppService.GetRootListAsync();

                    data = new OrgVm
                    {
                        Departments = _mapper.Map <List <DepartmentListVm> >(departments),
                        Employees   = _mapper.Map <List <EmployeeListVm> >(employees)
                    };

                    var cacheEntryOptions = new MemoryCacheEntryOptions()
                                            .SetAbsoluteExpiration(CacheKeys.DefaultCacheAbsoluteExpiration);

                    _cache.Set(CacheKeys.EnterpriseContact_GetRoots, data, cacheEntryOptions);
                }

                return(data);
            }
            catch (Exception ex)
            {
                return(BadRequest(LogError(_logger, ex)));
            }
        }
コード例 #2
0
ファイル: OrgManager.cs プロジェクト: ahmedekdawy/LMIS
        public ModelResponse SignUp(ref OrgVm vm, string password, string fileFolder)
        {
            try
            {
                //Validations
                var ret = ValidateOrgProfile(vm, fileFolder);
                if (ret != null)
                {
                    return(ret);
                }

                //Verify Auth Letter File Path
                if (!File.Exists(Path.Combine(fileFolder, vm.AuthLetterFileName)))
                {
                    return(new ModelResponse(102));
                }

                //Save to DB
                vm.Approval = Approval.Pending;
                Repo.SignUp(ref vm);
            }
            catch (Exception ex)
            {
                return(new ModelResponse(ex));
            }

            return(new ModelResponse(0, vm.PortalUserId));
        }
コード例 #3
0
ファイル: OrgManager.cs プロジェクト: ahmedekdawy/LMIS
        private static ModelResponse ValidateOrgProfile(OrgVm vm, string fileFolder)
        {
            //Validations
            if (vm.OrgType.IsNotASubCode() ||
                vm.OrgName.IsNullOrWhiteSpace() ||
                vm.OrgSize.IsNotASubCode() ||
                vm.IDType.IsNotASubCode() ||
                vm.ID.HasNoValue() ||
                vm.DateEstablished.Year < 1000 ||
                vm.Activity.IsNotASubCode() ||
                vm.ContactInfo == null ||
                vm.ContactInfo.Country.IsNotASubCode() ||
                vm.ContactInfo.City.IsNotASubCode() ||
                vm.ContactInfo.PostalCode.HasNoValue())
            {
                return(new ModelResponse(1));
            }
            if (vm.OrgType == "10000003" && vm.YOE.IsNotASubCode())
            {
                return(new ModelResponse(1));
            }
            if (vm.Activity == "03200004" && vm.Industry.IsNotASubCode() && vm.OtherIndustry.IsNullOrWhiteSpace())
            {
                return(new ModelResponse(1));
            }

            //Verify File Paths
            if (fileFolder.HasNoValue())
            {
                return(new ModelResponse(102));
            }
            if (!vm.LogoFileName.HasNoValue())
            {
                if (!File.Exists(Path.Combine(fileFolder, vm.LogoFileName)))
                {
                    return(new ModelResponse(102));
                }
            }
            if (!vm.ProfileFileName.HasNoValue())
            {
                if (!File.Exists(Path.Combine(fileFolder, vm.ProfileFileName)))
                {
                    return(new ModelResponse(102));
                }
            }

            return(null);
        }
コード例 #4
0
        public async Task <ActionResult <OrgVm> > GetChildren(Guid parentDepartmentId)
        {
            try
            {
                var departments = await _departmentAppService.GetListByParentIdAsync(parentDepartmentId);

                var employees = await _employeeAppService.GetListByDepartmentIdAsync(parentDepartmentId);

                var data = new OrgVm
                {
                    Departments = _mapper.Map <List <DepartmentListVm> >(departments),
                    Employees   = _mapper.Map <List <EmployeeListVm> >(employees)
                };

                return(data);
            }
            catch (Exception ex)
            {
                return(BadRequest(LogError(_logger, ex)));
            }
        }
コード例 #5
0
ファイル: SignUp.aspx.cs プロジェクト: ahmedekdawy/LMIS
        public static object OrgSignUp(OrgVm data, string password)
        {
            ApplicationUser user = null;

            try
            {
                user = new ApplicationUser()
                {
                    UserName = data.UserName, Email = data.UserName
                };
                UserMgr.PasswordValidator = new PasswordValidator()
                {
                    RequireUppercase = false
                };

                var ir = UserMgr.Create(user, password);
                if (!ir.Succeeded)
                {
                    return(IdentityErrors(ir.Errors));
                }

                var mr = OrgMgr.SignUp(ref data, password, Utils.UploadFolder);
                if (mr.Status == ResponseStatus.Success)
                {
                    return(Utils.ServiceResponse(PageCode, mr));
                }

                UserMgr.Delete(user);
                return(Utils.ServiceResponse(PageCode, mr));
            }
            catch (Exception ex)
            {
                if (user != null)
                {
                    UserMgr.Delete(user);
                }
                return(Utils.ServiceResponse(new ModelResponse(ex)));
            }
        }
コード例 #6
0
ファイル: OrgManager.cs プロジェクト: ahmedekdawy/LMIS
        public ModelResponse UpdateProfile(UserInfo user, ref OrgVm vm, string fileFolder)
        {
            try
            {
                //Authorization
                if (user == null)
                {
                    return(new ModelResponse(101));
                }
                if (string.IsNullOrWhiteSpace(user.UserId))
                {
                    return(new ModelResponse(101));
                }
                if (PUserRepo.GetUserClass(user) != UserClass.OrgAdmin)
                {
                    return(new ModelResponse(101));
                }

                //Validations
                var ret = ValidateOrgProfile(vm, fileFolder);
                if (ret != null)
                {
                    return(ret);
                }

                //Update DB
                vm.PortalUserId = (long)user.PortalUserId;
                vm.Approval     = Approval.Pending;
                Repo.UpdateProfile(ref vm, user.UserId);
            }
            catch (Exception ex)
            {
                return(new ModelResponse(ex));
            }

            return(new ModelResponse(0, vm.PortalUserId));
        }
コード例 #7
0
ファイル: OrgRepository.cs プロジェクト: ahmedekdawy/LMIS
        public void UpdateProfile(ref OrgVm vm, string userId)
        {
            using (var db = new LMISEntities())
                using (var transaction = db.Database.BeginTransaction())
                {
                    try
                    {
                        var portalUserId   = vm.PortalUserId;
                        var isSelfEmployed = vm.OrgType == "10000003";
                        var isIndustrial   = vm.Activity == "03200004";
                        var otherIndustry  = vm.OtherIndustry;
                        var telephoneNo    = vm.ContactInfo.Telephone;

                        if (string.IsNullOrWhiteSpace(vm.Industry))
                        {
                            vm.Industry = "";
                        }
                        else if (vm.Industry.Length != 8)
                        {
                            vm.Industry = "";
                        }
                        if (!isIndustrial || vm.Industry.Length == 8)
                        {
                            otherIndustry = new GlobalString();
                        }
                        if (telephoneNo == null)
                        {
                            telephoneNo = "";
                        }

                        var portalUser = db.PortalUsers.Single(r => r.PortalUsersID == portalUserId);

                        portalUser.IDType           = vm.IDType;
                        portalUser.IDNumber         = vm.ID;
                        portalUser.UserSubCategory  = vm.OrgType;
                        portalUser.TrainingSeeker   = vm.ReceiveTraining;
                        portalUser.TrainingProvider = vm.OfferTraining;
                        portalUser.Employer         = vm.OfferJobs;

                        var org = db.OrganizationDetails.Single(r => r.PortalUsersID == portalUserId);

                        org.OrganizationLogoPath    = string.IsNullOrWhiteSpace(vm.LogoFileName) ? "" : vm.LogoFileName;
                        org.OrganizationProfilePath = vm.ProfileFileName;
                        org.OrganizationSize        = vm.OrgSize;
                        org.CountryID                 = vm.ContactInfo.Country;
                        org.CityID                    = vm.ContactInfo.City;
                        org.ZipPostalCode             = vm.ContactInfo.PostalCode;
                        org.Telephone                 = telephoneNo;
                        org.OrganizationWebsite       = vm.ContactInfo.Website;
                        org.EconomicActivity          = vm.Activity;
                        org.IndustryType              = isIndustrial ? vm.Industry : null;
                        org.EstablishmentDate         = vm.DateEstablished;
                        org.YearsofExperienceID       = isSelfEmployed ? vm.YOE : "";
                        org.RegistrationNumberWithITC = vm.OfferTraining ? vm.ItcRegNo : null;
                        org.Is_Approved               = (byte)vm.Approval;
                        org.UpdateDate                = DateTime.UtcNow;
                        org.UpdateUserID              = userId;

                        db.OrganizationDetails_Det.RemoveRange(org.OrganizationDetails_Det);

                        var orgDets = Utils.MultilingualDataSet(
                            new Dictionary <string, GlobalString>
                        {
                            { "c1", vm.OrgName },
                            { "c2", vm.ContactInfo.Address },
                            { "c3", otherIndustry }
                        });

                        foreach (var r in orgDets)
                        {
                            org.OrganizationDetails_Det.Add(new OrganizationDetails_Det()
                            {
                                LanguageID        = r["c1"].L,
                                OrganizationName  = r["c1"].T,
                                Address           = r["c2"].T,
                                OtherIndustryType = r["c3"].T
                            });
                        }

                        var orgAdmin = org.OrganizationContact_Info.Single(r =>
                                                                           r.PortalUsersID == portalUserId && r.UserID == userId &&
                                                                           r.JobTitleID.Trim().ToLower() == "admin");

                        orgAdmin.Telephone    = telephoneNo;
                        orgAdmin.UpdateDate   = DateTime.UtcNow;
                        orgAdmin.UpdateUSerID = userId;

                        db.SaveChanges();
                        transaction.Commit();
                    }
                    catch (DbEntityValidationException ex)
                    {
                        transaction.Rollback();
                        ExceptionDispatchInfo.Capture(ex).Throw();
                    }
                    catch (Exception ex)
                    {
                        transaction.Rollback();
                        ExceptionDispatchInfo.Capture(ex).Throw();
                    }
                }
        }
コード例 #8
0
ファイル: OrgRepository.cs プロジェクト: ahmedekdawy/LMIS
        public long SignUp(ref OrgVm vm)
        {
            using (var db = new LMISEntities())
                using (var transaction = db.Database.BeginTransaction())
                {
                    try
                    {
                        var userName       = vm.UserName;
                        var userId         = db.AspNetUsers.Where(u => u.UserName == userName).Select(u => u.Id).Single();
                        var isSelfEmployed = vm.OrgType == "10000003";
                        var isIndustrial   = vm.Activity == "03200004";
                        var otherIndustry  = vm.OtherIndustry;
                        var telephoneNo    = vm.ContactInfo.Telephone;

                        if (string.IsNullOrWhiteSpace(vm.Industry))
                        {
                            vm.Industry = "";
                        }
                        else if (vm.Industry.Length != 8)
                        {
                            vm.Industry = "";
                        }
                        if (!isIndustrial || vm.Industry.Length == 8)
                        {
                            otherIndustry = new GlobalString();
                        }
                        if (telephoneNo == null)
                        {
                            telephoneNo = "";
                        }

                        var portalUser = db.PortalUsers.Add(new PortalUser()
                        {
                            IDType           = vm.IDType,
                            IDNumber         = vm.ID,
                            UserCategory     = "ORG",
                            UserSubCategory  = vm.OrgType,
                            TrainingSeeker   = vm.ReceiveTraining,
                            TrainingProvider = vm.OfferTraining,
                            Employer         = vm.OfferJobs,
                            JobSeeker        = false,
                            Researcher       = true,
                            Internal         = false,
                            IsSubscriper     = false
                        });

                        db.SaveChanges();
                        var portalUserId = portalUser.PortalUsersID;
                        vm.PortalUserId = (long)portalUserId;

                        var org = db.OrganizationDetails.Add(new OrganizationDetail()
                        {
                            PortalUsersID           = portalUserId,
                            OrganizationLogoPath    = string.IsNullOrWhiteSpace(vm.LogoFileName) ? "" : vm.LogoFileName,
                            OrganizationProfilePath = vm.ProfileFileName,
                            OrganizationSize        = vm.OrgSize,
                            CountryID                 = vm.ContactInfo.Country,
                            CityID                    = vm.ContactInfo.City,
                            ZipPostalCode             = vm.ContactInfo.PostalCode,
                            Telephone                 = telephoneNo,
                            OrganizationWebsite       = vm.ContactInfo.Website,
                            EconomicActivity          = vm.Activity,
                            IndustryType              = isIndustrial ? vm.Industry : null,
                            EstablishmentDate         = vm.DateEstablished,
                            YearsofExperienceID       = isSelfEmployed ? vm.YOE : "",
                            RegistrationNumberWithITC = vm.OfferTraining ? vm.ItcRegNo : null,
                            IsDiscalaimerApproved     = true,
                            Is_Approved               = (byte)vm.Approval,
                            PostDate                  = DateTime.UtcNow
                        });

                        var orgDets = Utils.MultilingualDataSet(
                            new Dictionary <string, GlobalString>
                        {
                            { "c1", vm.OrgName },
                            { "c2", vm.ContactInfo.Address },
                            { "c3", otherIndustry }
                        });

                        foreach (var r in orgDets)
                        {
                            org.OrganizationDetails_Det.Add(new OrganizationDetails_Det()
                            {
                                LanguageID        = r["c1"].L,
                                OrganizationName  = r["c1"].T,
                                Address           = r["c2"].T,
                                OtherIndustryType = r["c3"].T
                            });
                        }

                        org.OrganizationContact_Info.Add(new OrganizationContact_Info()
                        {
                            UserID     = userId,
                            JobTitleID = "admin",
                            Telephone  = telephoneNo,
                            Mobile     = "",
                            Email      = vm.UserName,
                            AuthorizationletterPath = vm.AuthLetterFileName,
                            IsApproved = (byte)vm.Approval,
                            PostDate   = DateTime.UtcNow,
                            PostUSerID = userId
                        });

                        db.SaveChanges();
                        transaction.Commit();
                    }
                    catch (DbEntityValidationException ex)
                    {
                        transaction.Rollback();
                        ExceptionDispatchInfo.Capture(ex).Throw();
                    }
                    catch (Exception ex)
                    {
                        transaction.Rollback();
                        ExceptionDispatchInfo.Capture(ex).Throw();
                    }
                }

            return(vm.PortalUserId);
        }
コード例 #9
0
        public static object OrgUpdate(OrgVm data)
        {
            var mr = OrgMgr.UpdateProfile(Utils.LoggedUser, ref data, Utils.UploadFolder);

            return(Utils.ServiceResponse(PageCode, mr));
        }