Exemple #1
0
 public int GetTotalAdApplications(string userId)
 {
     using (JobMtaaniDbContext entityContext = new JobMtaaniDbContext())
     {
         return((from e in entityContext.AdApplicationSet
                 where e.AdApplicantId == userId
                 select e).Count());
     }
 }
Exemple #2
0
 public AdApplication FindbyHireModel(string userName, int adId)
 {
     using (JobMtaaniDbContext entityContext = new JobMtaaniDbContext())
     {
         return((from e in entityContext.AdApplicationSet
                 where e.AdApplicantId == userName && e.AdId == adId
                 select e).FirstOrDefault());
     }
 }
Exemple #3
0
 public Ad[] GetPersonalAds(string userId)
 {
     using (JobMtaaniDbContext entityContext = new JobMtaaniDbContext())
     {
         return((from e in entityContext.AdSet
                 where e.AccountId == userId
                 select e).ToArray());
     }
 }
Exemple #4
0
 public AdApplication GetSuccesfulAdApplication(int adId)
 {
     using (JobMtaaniDbContext entityContext = new JobMtaaniDbContext())
     {
         return((from e in entityContext.AdApplicationSet
                 where e.AdId == adId && e.Status == ApplicationStatus.Accepted
                 select e).FirstOrDefault());
     }
 }
Exemple #5
0
 public int GetTotalAds()
 {
     using (JobMtaaniDbContext entityContext = new JobMtaaniDbContext())
     {
         return((from e in entityContext.AdSet
                 where e.AdClosed == false
                 select e).Count());
     }
 }
Exemple #6
0
 public int GetTotalUserReviews(string userId)
 {
     using (JobMtaaniDbContext entityContext = new JobMtaaniDbContext())
     {
         return((from e in entityContext.ReviewSet
                 where e.ReviewFor == userId
                 select e).Count());
     }
 }
Exemple #7
0
 public List <string> GetAdApplicant(int adId)
 {
     using (JobMtaaniDbContext entityContext = new JobMtaaniDbContext())
     {
         return((from e in entityContext.AdApplicationSet
                 where e.AdId == adId
                 select e.AdApplicantId).ToList());
     }
 }
Exemple #8
0
 public AdApplication[] GetAdApplicationsById(int adId)
 {
     using (JobMtaaniDbContext entityContext = new JobMtaaniDbContext())
     {
         return((from e in entityContext.AdApplicationSet
                 where e.AdId == adId && e.Status == ApplicationStatus.Open
                 select e).ToArray());
     }
 }
Exemple #9
0
 public Ad[] GetApplyAds(string userId)
 {
     using (JobMtaaniDbContext entityContext = new JobMtaaniDbContext())
     {
         return((from e in entityContext.AdSet
                 where e.AccountId != userId
                 where e.AdClosed == false
                 select e).ToArray());
     }
 }
Exemple #10
0
 public Ad[] GetTopAds()
 {
     using (JobMtaaniDbContext entityContext = new JobMtaaniDbContext())
     {
         return((from e in entityContext.AdSet
                 where e.AdClosed == false
                 orderby e.DateCreated descending
                 select e).Take(12).ToArray());
     }
 }
Exemple #11
0
 public Ad[] GetAdByCategory(int categoryId)
 {
     using (JobMtaaniDbContext entityContext = new JobMtaaniDbContext())
     {
         return((from a in entityContext.AdSet
                 where a.AdClosed == false
                 where a.CategoryId == categoryId
                 select a).ToArray());
     }
 }
Exemple #12
0
 public Ad[] GetByLocation(string userId)
 {
     using (JobMtaaniDbContext entityContext = new JobMtaaniDbContext())
     {
         return((from e in entityContext.AdSet
                 where e.AccountId != userId
                 where e.AdClosed == false
                 orderby e.DateCreated descending
                 select e).Take(7).ToArray <Ad>());
     }
 }
Exemple #13
0
 public int GetTotalUserAds(string userId, bool forUser)
 {
     using (JobMtaaniDbContext entityContext = new JobMtaaniDbContext())
     {
         if (!forUser)
         {
             return((from e in entityContext.AdSet
                     where e.AccountId != userId
                     select e).Count());
         }
         return((from e in entityContext.AdSet
                 where e.AccountId == userId
                 select e).Count());
     }
 }
Exemple #14
0
        public Review[] GetUserReviews(string userId, int pageNumber)
        {
            if (pageNumber == 0)
            {
                pageNumber = 1;
            }

            int pageSize = 10;
            int skip     = (pageNumber * pageSize) - pageSize;

            using (JobMtaaniDbContext entityContext = new JobMtaaniDbContext())
            {
                return((from e in entityContext.ReviewSet
                        where e.ReviewFor == userId
                        orderby e.DateCreated descending
                        select e).Skip(skip).Take(pageSize).ToArray());
            }
        }
Exemple #15
0
        public Ad[] GetAllAdsPaged(int pageId)
        {
            if (pageId == 0)
            {
                pageId = 1;
            }

            int pageSize = 12;
            int skip     = (pageId * pageSize) - pageSize;

            using (JobMtaaniDbContext entityContext = new JobMtaaniDbContext())
            {
                return((from e in entityContext.AdSet
                        where e.AdClosed == false
                        orderby e.DateCreated descending
                        select e).Skip(skip).Take(pageSize).ToArray());
            }
        }
Exemple #16
0
        public List <AdApplication> FindUserAdApplications(string userId, int pageNumber)
        {
            if (pageNumber == 0)
            {
                pageNumber = 1;
            }

            int pageSize = 10;
            int skip     = (pageNumber * pageSize) - pageSize;

            using (JobMtaaniDbContext entityContext = new JobMtaaniDbContext())
            {
                return((from e in entityContext.AdApplicationSet
                        where e.AdApplicantId == userId
                        orderby e.DateApplied descending
                        select e).ToList());
            }
        }
Exemple #17
0
        public Ad[] GetPageAds(string userId, int pageNumber, bool userOwned)
        {
            if (pageNumber == 0)
            {
                pageNumber = 1;
            }

            int pageSize = 10;
            int skip     = (pageNumber * pageSize) - pageSize;

            using (JobMtaaniDbContext entityContext = new JobMtaaniDbContext())
            {
                if (!userOwned)
                {
                    Ad[] ads = (from e in entityContext.AdSet
                                where e.AccountId != userId
                                orderby e.DateCreated descending
                                select e).Skip(skip).Take(pageSize).ToArray();

                    foreach (var ad in ads)
                    {
                        AdApplication adApplication = (from e in entityContext.AdApplicationSet
                                                       where e.AdId == ad.AdId && e.AdApplicantId == userId
                                                       select e).FirstOrDefault();
                        if (adApplication != null)
                        {
                            ad.AdApplied = true;
                        }
                    }

                    return(ads);
                }
                else
                {
                    return((from e in entityContext.AdSet
                            where e.AccountId == userId
                            orderby e.DateCreated descending
                            select e).Skip(skip).Take(pageSize).ToArray());
                }
            }
        }
Exemple #18
0
 public Ad[] GetBySearchTerms(SearchModel searchModel)
 {
     using (JobMtaaniDbContext entityContext = new JobMtaaniDbContext())
     {
         if (searchModel.JobLocation != null)
         {
             return((from e in entityContext.AdSet
                     where e.AdClosed == false
                     where (e.AdTitle.Contains(searchModel.SearchTerm) ||
                            e.AdDescription.Contains(searchModel.SearchTerm)) &&
                     e.AdLocation == searchModel.JobLocation
                     select e).ToArray());
         }
         else
         {
             return((from e in entityContext.AdSet
                     where e.AdClosed == false
                     where (e.AdTitle.Contains(searchModel.SearchTerm) ||
                            e.AdDescription.Contains(searchModel.SearchTerm))
                     select e).ToArray());
         }
     }
 }
 protected override IEnumerable <Category> GetEntities(JobMtaaniDbContext entityContext)
 {
     return(from e in entityContext.CategorySet
            select e);
 }
 protected override Category AddEntity(JobMtaaniDbContext entityContext, Category entity)
 {
     return(entityContext.CategorySet.Add(entity));
 }
Exemple #21
0
 protected override Payment UpdateEntity(JobMtaaniDbContext entityContext, Payment entity)
 {
     return((from e in entityContext.PaymentSet
             where e.PaymentId == entity.PaymentId
             select e).FirstOrDefault());
 }
Exemple #22
0
 protected override Payment GetEntity(JobMtaaniDbContext entityContext, int id)
 {
     return((from e in entityContext.PaymentSet
             where e.PaymentId == id
             select e).FirstOrDefault());
 }
Exemple #23
0
 protected override IEnumerable <Payment> GetEntities(JobMtaaniDbContext entityContext)
 {
     return(from e in entityContext.PaymentSet
            select e);
 }
Exemple #24
0
 protected override Payment AddEntity(JobMtaaniDbContext entityContext, Payment entity)
 {
     return(entityContext.PaymentSet.Add(entity));
 }
 protected override Subscription GetEntity(JobMtaaniDbContext entityContext, int id)
 {
     return((from e in entityContext.SubscriptionSet
             where e.SubscriptionId == id
             select e).FirstOrDefault());
 }
 protected override IEnumerable <Subscription> GetEntities(JobMtaaniDbContext entityContext)
 {
     return(from e in entityContext.SubscriptionSet
            select e);
 }
 protected override Subscription AddEntity(JobMtaaniDbContext entityContext, Subscription entity)
 {
     return(entityContext.SubscriptionSet.Add(entity));
 }
 protected override Category GetEntity(JobMtaaniDbContext entityContext, int id)
 {
     return((from e in entityContext.CategorySet
             where e.CategoryId == id
             select e).FirstOrDefault());
 }
 protected override Category UpdateEntity(JobMtaaniDbContext entityContext, Category entity)
 {
     return((from e in entityContext.CategorySet
             where e.CategoryId == entity.CategoryId
             select e).FirstOrDefault());
 }
 protected override Subscription UpdateEntity(JobMtaaniDbContext entityContext, Subscription entity)
 {
     return((from e in entityContext.SubscriptionSet
             where e.SubscriptionId == entity.SubscriptionId
             select e).FirstOrDefault());
 }