// GET: api/FieldType
    public NgTable <FieldTypesViewModel> Get()
    {
        var queryTableParams = new NgTableParams();
        NgTable <FieldTypesViewModel> result = FieldTypeService.List(queryTableParams, null);

        return(result);
    }
Example #2
0
    // GET: api/AomObject
    public NgTable <AomObjectViewModel> Get()
    {
        var queryTableParams = new NgTableParams();
        NgTable <AomObjectViewModel> result = AomObjectService.List(queryTableParams, null);

        return(result);
    }
Example #3
0
    // GET: api/RelationshipMeta
    public NgTable <RelationshipMetaViewModel> Get()
    {
        var queryTableParams = new NgTableParams();
        NgTable <RelationshipMetaViewModel> result = RelationshipMetaService.List(queryTableParams, null);

        return(result);
    }
        public async Task <NgTable <CandidateCardViewModel> > GetRelevantCandidatesForJob(Guid jobId, UserViewModel userViewModel)
        {
            NgTable <CandidateCardViewModel> result = new NgTable <CandidateCardViewModel>();

            var skillIds = this.UnitOfWork.With <Database.JobSkill>().Where(c => c.JobId == jobId).Select(c => c.SkillId).ToArray();

            var queryResult = this.UnitOfWork.With <Database.Candidate>()
                              .Where(c =>
                                     (!c.EmployerResponse.Any() || c.EmployerResponse.All(cr => cr.JobId != jobId)) &&
                                     c.CandidateSkill.Any(cc => skillIds.Contains(cc.SkillId)))
                              .Select(c => new CandidateCardViewModel
            {
                CandidateId = c.Id,
                Skills      = c.CandidateSkill.Select(cc => new CandidateSkillViewModel
                {
                    SkillId    = cc.SkillId,
                    SkillLevel = cc.SkillLevel,
                    Skill      = new Database.Skill
                    {
                        SkillName = cc.Skill.SkillName
                    }
                }).ToArray()
            })
                              .Take(1000)
                              .ToList();

            result.Data = queryResult.OrderByDescending(o => o.Skills.Count(c => skillIds.Contains(c.SkillId))).ToList();

            result.Success = true;

            return(result);
        }
Example #5
0
        public async Task <NgTable <JobCardViewModel> > GetRelevantJobsForCandidate(UserViewModel userViewModel)
        {
            NgTable <JobCardViewModel> result = new NgTable <JobCardViewModel>();

            var skillIds = UnitOfWork.With <Database.Candidate>().Find(userViewModel.CandidateId).CandidateSkill.Select(cc => cc.SkillId).ToList();

            var queryResult = UnitOfWork.With <Database.Job>()
                              .Where(c =>
                                     (!c.CandidateResponse.Any() || c.CandidateResponse.All(cr => cr.CandidateId != userViewModel.CandidateId)) &&
                                     c.JobSkill.Any(cc => skillIds.Contains(cc.SkillId)))
                              .Select(c => new JobCardViewModel
            {
                JobId  = c.Id,
                Skills = c.JobSkill.Select(cc => new CandidateSkillViewModel
                {
                    SkillId = cc.SkillId,
                    Skill   = new Database.Skill
                    {
                        SkillName = cc.Skill.SkillName
                    }
                }).ToArray()
            })
                              .Take(1000)
                              .ToArray();

            result.Data = queryResult.OrderByDescending(o => o.Skills.Count(c => skillIds.Contains(c.SkillId))).ToList();

            result.Success = true;

            return(result);
        }
        public bool Run(NgTableParams model, ref IQueryable <AomMeta> repository, NgTable <AomMetaViewModel> result, ICoreUser user, IUnitOfWork db)
        {
            var ngTransformer = new QueryToNgTable <AomMetaViewModel>();

            var query = AomMetaMapper.MapDbModelQueryToViewModelQuery(repository);

            ngTransformer.ToNgTableDataSet(model, query, result);
            return(true);
        }
Example #7
0
        public NgTable <T> List(NgTableParams ngTableParams, ICoreUser user)
        {
            var result = new NgTable <T>();

            if (!RunViewListBusinessLogic(new InterfaceLoader <IViewListRule <T, T2> >(), result, ngTableParams, user))
            {
                return(result);
            }

            if (!RunViewListDataLogic(new InterfaceLoader <IViewListEvent <T, T2> >(), result, ngTableParams, user))
            {
                return(result);
            }

            result.Success = true;
            return(result);
        }
Example #8
0
        public async Task <NgTable <T> > List(NgTableParams ngTableParams, ICoreUser user)
        {
            var result = new NgTable <T>();

            //if (!RunRepoLogic(new InterfaceLoader<IRepoRule<T, T2>>(), result, model, user))
            //    return result;

            if (!RunViewListBusinessLogic(new InterfaceLoader <IViewListRule <T, T2> >(), result, ngTableParams, user))
            {
                return(result);
            }

            if (!RunViewListDataLogic(new InterfaceLoader <IViewListEvent <T, T2> >(), result, ngTableParams, user))
            {
                return(result);
            }

            result.Success = true;
            return(result);
        }
Example #9
0
 public bool Run(NgTableParams model, ref IQueryable <AomObject> repository, NgTable <AomObject> result, ICoreUser user, IUnitOfWork unitOfWork)
 {
     // limit by organisation owner etc... business rules
     //   throw new NotImplementedException();
 }
Example #10
0
    // POST: api/AomObject
    public NgTable <AomObjectViewModel> Post(NgTableParams queryTableParams)
    {
        NgTable <AomObjectViewModel> result = AomObjectService.List(queryTableParams, null);

        return(result);
    }
Example #11
0
    // POST: api/RelationshipMeta
    public NgTable <RelationshipMetaViewModel> Post(NgTableParams queryTableParams)
    {
        NgTable <RelationshipMetaViewModel> result = RelationshipMetaService.List(queryTableParams, null);

        return(result);
    }
        public NgTable <AomMeta> CreateTables(string userName, string password, string[] tables)
        {
            var result = new NgTable <AomMeta>();
            // 1. Log in to sales force
            var loggedIn = Connector.LogIn(userName, password);

            if (!loggedIn.Data)
            {
                result.LogError("Could not log into sales force");
                return(result);
            }

            // 2. check that the tables are correct
            var  tableNames = Connector.GatTablesList();
            bool isSubset   = !tables.Except(tableNames).Any();

            if (!isSubset)
            {
                result.LogError("Tables are not a subset of salesforce tables");
                return(result);
            }

            // 2. get the table definitions

            //    var tableDefinitions = Connector.DescribeTables(tables);

            // lets gt all of them
            var listN = splitList(tableNames, 50);
            List <TableInfo> tableDefinitions = new List <TableInfo>();

            foreach (var list in listN)
            {
                tableDefinitions.AddRange(Connector.DescribeTables(list.ToArray()));
            }



            var context = new AomDbContext();

            foreach (var tableDefinition in tableDefinitions)
            {
                if (!tables.ToList().Contains(tableDefinition.name))
                {
                    continue;
                }
                // 3. create table for each table definition
                AomMeta newTable = new AomMeta
                {
                    Name    = tableDefinition.name,
                    Display = tableDefinition.label
                };

                // 4. create table field for each definition
                foreach (var field in tableDefinition.fields)
                {
                    // 5. create a type for each field type
                    var fieldType = context.FieldTypes.FirstOrDefault(c => c.Name == field.type);
                    if (fieldType == null)
                    {
                        fieldType = new FieldType
                        {
                            Name = field.type
                        };
                        context.FieldTypes.Add(fieldType);
                        context.SaveChanges();
                    }

                    AomFieldMeta newField = new AomFieldMeta
                    {
                        Name      = field.name,
                        Display   = field.label,
                        FieldType = fieldType
                                    // FieldTypeId = new Guid("F96D8BB4-C3E4-437B-A8AE-9E6BCB9CFE52")
                    };
                    newTable.AomFieldMetas.Add(newField);
                }

                result.Data.Add(newTable);
                context.AomMetas.Add(newTable);
            }
            context.SaveChanges();
            result.Success = true;


            // 5 create ralationships
            foreach (var tableDefinition in tableDefinitions)
            {
                // primary key table - which is this table
                var primaryTable = context.AomMetas.SingleOrDefault(c => c.Name == tableDefinition.name);

                if (primaryTable == null)
                {
                    continue;
                }

                // primary key table field - which is this tables Id
                var primaryTableField =
                    context.AomFieldMetas.SingleOrDefault(c => c.Name == "Id" && c.AomMetaId == primaryTable.Id);
                if (primaryTableField == null)
                {
                    continue;
                }


                if (tableDefinition.relationships == null)
                {
                    continue;
                }

                foreach (var relationship in tableDefinition.relationships)
                {
                    // forigen key table - the ccurrent child table
                    var forigenTable = context.AomMetas.SingleOrDefault(c => c.Name == relationship.ChildTable);
                    if (forigenTable == null)
                    {
                        continue;
                    }

                    // forigen key table field
                    var forigenTableField =
                        context.AomFieldMetas.SingleOrDefault(c => c.Name == relationship.ChildField && c.AomMetaId == forigenTable.Id);
                    if (forigenTableField == null)
                    {
                        continue;
                    }


                    // yeah baby we have a valid relationship SWEET AS
                    context.RelationshipMetas.Add(new RelationshipMeta
                    {
                        PkAomMetaId      = primaryTable.Id,
                        FkAomMetaId      = forigenTable.Id,
                        FkAomFieldMetaId = forigenTableField.Id,
                        PkAomFieldMetaId = primaryTableField.Id
                    });
                    context.SaveChanges();
                }
            }

            return(result);
        }
    // POST: api/AomFieldMeta
    public NgTable <AomFieldMetaViewModel> Post(NgTableParams queryTableParams)
    {
        NgTable <AomFieldMetaViewModel> result = AomFieldMetaService.List(queryTableParams, null);

        return(result);
    }
    // POST: api/FieldType
    public NgTable <FieldTypesViewModel> Post(NgTableParams queryTableParams)
    {
        NgTable <FieldTypesViewModel> result = FieldTypeService.List(queryTableParams, null);

        return(result);
    }
Example #15
0
        public bool Run(NgTableParams model, ref IQueryable <Database.Candidate> repository, NgTable <CandidateViewModel> result, ICoreUser Candidate, IUnitOfWork db)
        {
            var ngTransformer = new QueryToNgTable <CandidateViewModel>();

            var query = CandidateMapper.MapDbModelQueryToViewModelQuery(repository);

            ngTransformer.ToNgTableDataSet(model, query, result);
            return(true);
        }
Example #16
0
 public bool Run(NgTableParams model, ref IQueryable <AomFieldObject> repository, NgTable <AomFieldObjectViewModel> result, ICoreUser user, IUnitOfWork unitOfWork)
 {
     // unitOfWork = unitOfWork.Where(c => c.OwnerId == null);
     // limit by organisation owner etc... business rules
     return(true);
 }
Example #17
0
 private bool RunViewListBusinessLogic(InterfaceLoader <IViewListRule <T, T2> > interfaceLoader, NgTable <T> result, NgTableParams ngTableParams, ICoreUser user)
 {
     foreach (var interfaceImplementation in interfaceLoader.InterfaceImplementations)
     {
         if (!interfaceImplementation.Run(ngTableParams, ref DbSet, result, user, UnitOfWork))
         {
             return(false);
         }
     }
     return(true);
 }