Exemplo n.º 1
0
        public async Task <T> AddSingleAsync(T item)
        {
            using (var context = new apptrackEntities())
            {
                context.Set <T>().Add(item);
                await context.SaveChangesAsync();

                return(item);
            }
        }
Exemplo n.º 2
0
 public void Remove(params T[] items)
 {
     using (var context = new apptrackEntities())
     {
         foreach (T item in items)
         {
             context.Entry(item).State = System.Data.Entity.EntityState.Deleted;
         }
         context.SaveChanges();
     }
 }
Exemplo n.º 3
0
 public virtual async Task UpdateAsync(params T[] items)
 {
     using (var context = new apptrackEntities())
     {
         foreach (T item in items)
         {
             context.Entry(item).State = System.Data.Entity.EntityState.Modified;
         }
         await context.SaveChangesAsync();
     }
 }
Exemplo n.º 4
0
 public virtual async Task RemoveAsync(params T[] items)
 {
     try
     {
         using (var context = new apptrackEntities())
         {
             foreach (T item in items)
             {
                 context.Entry(item).State = System.Data.Entity.EntityState.Deleted;
             }
             await context.SaveChangesAsync();
         }
     }
     catch (DbEntityValidationException e)
     {
     }
 }
Exemplo n.º 5
0
        public T GetSingle(Func <T, bool> where, params Expression <Func <T, object> >[] navigationProperties)
        {
            T item = null;

            using (var context = new apptrackEntities())
            {
                IQueryable <T> dbQuery = context.Set <T>();

                //Apply eager loading
                foreach (Expression <Func <T, object> > navigationProperty in navigationProperties)
                {
                    dbQuery = dbQuery.Include <T, object>(navigationProperty);
                }

                item = dbQuery
                       .AsNoTracking()         //Don't track any changes for the selected item
                       .FirstOrDefault(where); //Apply where clause
            }
            return(item);
        }
Exemplo n.º 6
0
        public async Task <IList <T> > GetAllAsync(params Expression <Func <T, object> >[] navigationProperties)
        {
            dynamic list = null;

            using (var context = new apptrackEntities())
            {
                IQueryable <T> dbQuery = context.Set <T>();

                //Apply eager loading
                foreach (Expression <Func <T, object> > navigationProperty in navigationProperties)
                {
                    dbQuery = dbQuery.Include <T, object>(navigationProperty);
                }

                list = dbQuery
                       .AsNoTracking()
                       .ToListAsync <T>();
            }
            return(await list);
        }
Exemplo n.º 7
0
        public IList <T> GetList(Func <T, bool> where, params Expression <Func <T, object> >[] navigationProperties)
        {
            List <T> list;

            using (var context = new apptrackEntities())
            {
                IQueryable <T> dbQuery = context.Set <T>();

                //Apply eager loading
                foreach (Expression <Func <T, object> > navigationProperty in navigationProperties)
                {
                    dbQuery = dbQuery.Include <T, object>(navigationProperty);
                }

                list = dbQuery
                       .AsNoTracking()
                       .Where(where)
                       .ToList <T>();
            }
            return(list);
        }
        public IList <SearchApplicant_Result> SearchApplicant(string searchText, string status, string company, string experience, string createdBy, string salary, string location, string industry, string days, int?startRecord, int?pageLimit, out int totalRecord)
        {
            List <SearchApplicant_Result> searchResultList;
            //ObjectResult<SearchApplicant_Result> candidateResults = null;
            dynamic candidateResults;

            try
            {
                ObjectParameter Output = new ObjectParameter("TotalRecord", typeof(Int32));

                using (var context = new apptrackEntities())
                {
                    candidateResults = context.SearchApplicant(searchText, status, company, experience, createdBy, salary, location, industry, days, startRecord, pageLimit, Output).ToList();
                    searchResultList = ConvertToSearchResultList(candidateResults);
                    totalRecord      = Output.Value == DBNull.Value ? 0 : Convert.ToInt32(Output.Value);
                }
                return(searchResultList);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Exemplo n.º 9
0
        public virtual async Task <IEnumerable <SearchApplicant_Result> > SearchApplicantAsync(string searchText, string status, string company, string experience, string createdBy, string salary, string location, string industry, string days, int?startRecord, int?pageLimit, int totalRecord)
        {
            dynamic result = null;

            try
            {
                ObjectParameter Output = new ObjectParameter("TotalRecord", typeof(Int32));
                using (var context = new apptrackEntities())
                {
                    await Task.Run(() =>
                    {
                        result = context.SearchApplicant(searchText, status, company, experience, createdBy, salary, location, industry, days, startRecord, pageLimit, Output).ToList();
                    });

                    totalRecord = Convert.ToInt32(Output.Value);
                }
                return(result);
            }
            catch (Exception)
            {
                throw;
            }
        }