public ActionResult RollcallList(string courseTime)
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(RedirectToRoute(new { controller = "Login", action = "Index" }));
            }
            int t_id = PageValidate.FilterParam(User.Identity.Name);
            //从教师ID中查找可点名科目
            DateTime minDt = DateTime.Now.AddMinutes(-10);

            var rc = (from c in db.Course_Infos
                      join cvt in db.Course_vs_Times
                      on c.course_id equals cvt.cvt_course_id
                      join r in db.Sys_ClassRooms
                      on cvt.cvt_room_id equals r.room_id into T1
                      from t1 in T1.DefaultIfEmpty()
                      join s in db.Dic_Schools
                      on t1.room_school_id equals s.school_id into T2
                      from t2 in T2.DefaultIfEmpty()
                      where (c.c_teacher_id == t_id || c.c_assistant_id == t_id) &&
                      DbFunctions.DiffDays(DateTime.Now, cvt.cvt_time) == 0 &&
                      (cvt.cvt_time >= minDt || DbFunctions.AddMinutes(cvt.cvt_time, cvt.cvt_duration) > DateTime.Now)
                      select new RollCallList
            {
                id = cvt.cvt_id,
                name = c.course_name,
                time = cvt.cvt_time
            }
                      );

            return(View(rc.ToList()));
        }
Esempio n. 2
0
 // GET: Histories/Grant/X       - grant history for all time or for X days
 public async Task <ActionResult> Grant(int?days)
 {
     return(days == null
         ? View(await _db.Histories.Where(h => !h.Recieved).OrderByDescending(h => h.Date).ToListAsync())
         : View(await _db.Histories.Where(h => !h.Recieved && DbFunctions.DiffDays(h.Date, DateTime.Now) < days)
                .OrderByDescending(h => h.Date).ToListAsync()));
 }
        public IHttpActionResult OrderToShippedReport()
        {
            /*
             *  Write a query to return an array of anonymous objects that have two properties.
             *
             *  1. A Shipper property containing that particular shipper.
             *  2. A OrderToShipped property containing the average amount of days between the OrderDate and ShippedDate by Shipper.
             *
             *  Return the rows ordered by OrderToShipped
             * ");*/
            var resultSet = _db.Shippers
                            .Select(s => new
            {
                Shipper = new
                {
                    s.ShipperID,
                    s.CompanyName,
                    s.Phone
                },
                OrderToShipped = s.Orders.Average(o => DbFunctions.DiffDays(o.OrderDate, o.ShippedDate))
            })
                            .OrderBy(s => s.OrderToShipped);

            Console.Write(resultSet);
            return(Ok(resultSet));
        }
 /// <summary>
 /// Get Daily appointments
 /// </summary>
 /// <param name="getDate"></param>
 /// <returns></returns>
 public IEnumerable <Appointment> GetDaillyAppointments(DateTime getDate)
 {
     return(_context.Appointments.Where(a => DbFunctions.DiffDays(a.StartDateTime, getDate) == 0)
            .Include(p => p.Pet)
            .Include(d => d.Doctor)
            .ToList());
 }
Esempio n. 5
0
 public ActionResult GetAllChungChiOfNV(string mnv = "")
 {
     using (QUANGHANHABCEntities db = new QUANGHANHABCEntities())
     {
         var temp = (from cc in db.ChungChis
                     join ccnv in db.ChungChi_NhanVien
                     on cc.MaChungChi equals ccnv.MaChungChi
                     where ccnv.MaNV.Equals(mnv)
                     select new
         {
             MaNV = ccnv.MaNV,
             TenChungChi = cc.TenChungChi,
             SoHieu = ccnv.SoHieu,
             NgayCap = ccnv.NgayCap,
             ConHan = (DbFunctions.DiffDays(DbFunctions.AddMonths(ccnv.NgayCap, cc.ThoiHan), DateTime.Now) < 0 ? "Hết Hạn" :
                       DbFunctions.DiffDays(DbFunctions.AddMonths(ccnv.NgayCap, cc.ThoiHan), DateTime.Now) >= 0 ? "Còn Hạn" : "Còn Hạn"
                       )
         });
         List <ChungChi_NhanVien_Model> arrChungChi = temp.ToList().Select(p => new ChungChi_NhanVien_Model
         {
             TenChungChi = p.TenChungChi,
             SoHieu      = p.SoHieu,
             NgayCap     = p.NgayCap,
             isConHan    = p.ConHan
         }).ToList();
         return(Json(new { success = true, data = arrChungChi }, JsonRequestBehavior.AllowGet));
     }
 }
Esempio n. 6
0
        public List <Poliza> FindAll(string numSolicitud, string fechaIngreso, decimal?monto)
        {
            var query = _db.Poliza.AsQueryable();

            if (!string.IsNullOrWhiteSpace(numSolicitud))
            {
                query = query.Where(p => p.Nu_Poliza == numSolicitud);
            }

            if (!string.IsNullOrWhiteSpace(fechaIngreso))
            {
                DateTime value;
                var      esValida = DateTime.TryParse(fechaIngreso, out value);

                if (esValida)
                {
                    query = query.Where(p => DbFunctions.DiffDays(p.Fe_Creacion, value).Value == 0);
                }
            }

            if (monto != null)
            {
                query = query.Where(p => p.Cap_Asegurado == monto);
            }

            return(query.OrderByDescending(p => p.Co_Poliza).ToList());
        }
Esempio n. 7
0
        public NotificationResultDto GetNewNotifications()
        {
            var currentUserId = User.Identity.GetUserId();
            var today         = DateTime.Now;

            var userNotifications = _context.UserNotifications
                                    .Where(u => u.UserId == currentUserId);

            var unreadNotifications = userNotifications
                                      .Where(u => !u.IsRead)
                                      .ToList()
                                      .Count;

            var notifications = userNotifications
                                .Select(u => u.Notification)
                                .Include(n => n.Teamup.Organizer)
                                .Where(n => DbFunctions.DiffDays(n.CreatedOn, today) <= 30)
                                .ToList();

            var notificationResultDto = new NotificationResultDto
            {
                Unread = unreadNotifications,
                All    = notifications.Select(Mapper.Map <Notification, NotificationDto>)
            };

            return(notificationResultDto);
        }
 public ICollection <GelirGiderAylıkDTO> GecikenOdemeleriGetir(DateTime dateTime, bool kontrol)
 {
     using (CRMContext _db = new CRMContext())
     {
         return((from finans in _db.FinansTakip
                 join urun in _db.Urun on finans.UrunID equals urun.ID into urunfinans
                 from Urun in urunfinans.DefaultIfEmpty()
                 join sporcu in _db.Sporcu on finans.SporcuID equals sporcu.ID into sporcufinans
                 from Sporcu in sporcufinans.DefaultIfEmpty()
                 join calisan in _db.Calisan on finans.CalisanID equals calisan.ID into calisanfinans
                 from Calisan in calisanfinans.DefaultIfEmpty()
                 join uye in _db.Uye on finans.UyeID equals uye.ID into uyefinans
                 from Uye in uyefinans.DefaultIfEmpty()
                 join kat in _db.GelirGiderKategori on finans.GelirGiderKategoriID equals kat.ID
                 where finans.GelirMiGiderMi == kontrol && finans.OdemeDurumu == false
                 select new GelirGiderAylıkDTO
         {
             ID = finans.ID,
             KategoriAdi = kat.GelirGiderKategoriAdi,
             UyeAdi = Uye.Ad,
             CalisanAdi = Calisan.Ad,
             SporcuAdi = Sporcu.Ad,
             UrunAdi = Urun.UrunAd,
             Fiyat = finans.Fiyat,
             OdemeDurumu = finans.OdemeDurumu,
             OdemeTarihi = finans.OdemeTarihi.Value,
             SonOdemeTarihi = finans.SonOdemeTarihi.Value
         }).Where(x => x.SonOdemeTarihi.Value.Month == dateTime.Month && x.SonOdemeTarihi.Value.Year == dateTime.Year &&
                  DbFunctions.DiffDays(x.SonOdemeTarihi, DateTime.Now) > 0).ToList());
     }
 }
 public ICollection <AylikGelirGiderDTO> KategoriBilgileriniGetir(string ad)
 {
     using (CRMContext _db = new CRMContext())
     {
         return((from finans in _db.FinansTakip
                 join urun in _db.Urun on finans.UrunID equals urun.ID into urunfinans
                 from Urun in urunfinans.DefaultIfEmpty()
                 join sporcu in _db.Sporcu on finans.SporcuID equals sporcu.ID into sporcufinans
                 from Sporcu in sporcufinans.DefaultIfEmpty()
                 join calisan in _db.Calisan on finans.CalisanID equals calisan.ID into calisanfinans
                 from Calisan in calisanfinans.DefaultIfEmpty()
                 join uye in _db.Uye on finans.UyeID equals uye.ID into uyefinans
                 from Uye in uyefinans.DefaultIfEmpty()
                 join kat in _db.GelirGiderKategori on finans.GelirGiderKategoriID equals kat.ID
                 where finans.AktifMi == true
                 where finans.OdemeDurumu == false
                 select new AylikGelirGiderDTO
         {
             ID = finans.ID,
             KategoriAdi = kat.GelirGiderKategoriAdi,
             UyeAdi = Uye.Ad,
             CalisanAdi = Calisan.Ad,
             SporcuAdi = Sporcu.Ad,
             UrunAdi = Urun.UrunAd,
             Fiyat = finans.Fiyat,
             SonOdemeTarihi = finans.SonOdemeTarihi.Value
         }).Where(x => x.KategoriAdi.Contains(ad) && DbFunctions.DiffDays(x.SonOdemeTarihi, DateTime.Now) > 0).ToList());
     }
 }
Esempio n. 10
0
 public ActionResult ManageOrganizationAccounts()
 {
     try
     {
         DateTime CurrentTimeNow = new DateTime();
         CurrentTimeNow = DateTime.Now;
         DateTime EndDate = CurrentTimeNow;
         return(Json(new
         {
             success = true,
             message = "Ok",
             data = db.OrganizationSettings.Select(x => new
             {
                 x.OrganizationID,
                 x.OrganizationNameInFull,
                 Subdomain = db.Catalog.Where(y => y.OrganizationID == x.OrganizationID).Select(y => y.SubDomain).FirstOrDefault(),
                 IsDemo = db.Catalog.Where(y => y.OrganizationID == x.OrganizationID).Select(y => y.IsDemo).FirstOrDefault(),
                 IsActive = db.Catalog.Where(y => y.OrganizationID == x.OrganizationID).Select(y => y.IsActive).FirstOrDefault(),
                 AccountStatus = db.Catalog.Where(y => y.OrganizationID == x.OrganizationID && (y.IsDemo == true || y.IsActive == true)).Select(y => (true) || (false)).FirstOrDefault(),
                 NumberOfDemoDaysLeft = DbFunctions.DiffDays(CurrentTimeNow, db.RequestForDemo.Where(z => z.OrganizationFullName == x.OrganizationNameInFull).Select(z => z.DemoEndDate).FirstOrDefault()),
                 // NumberOfActiveDaysLeft = DbFunctions.DiffDays(CurrentTimeNow, db.Catalog.Where(z => z.OrganizationID == x.OrganizationID).Select(z => z.ActiveEndDate).FirstOrDefault())
             })
         }, JsonRequestBehavior.AllowGet));
     }
     catch (Exception ex)
     {
         LogHelper.Log(Log.Event.ONBOARDING, ex.Message);
         return(Json(new
         {
             success = false,
             message = "" + ex.Message,
             data = new { }
         }, JsonRequestBehavior.AllowGet));
     }
 }
 /*
  * Efecto: devuelve lista de instancias de modelo RequirementDurationsModel para reporte de análisis de duración de requerimientos
  * Requiere: complejidad de requerimiento
  * Modifica: NA
  */
 public List <RequirementDurationsModel> GetRequirementDurationsInfo(int?complexity)
 {
     if (complexity != null)
     {
         IEnumerable <RequirementDurationsModel> info =
             from r in db.requerimientos
             where r.complejidad == complexity
             group r by r.complejidad into g
             select new RequirementDurationsModel
         {
             complexity       = g.Select(d => d.complejidad).FirstOrDefault(),
             requirementCount = g.Count(),
             minDiff          = g.Min(d => Math.Abs((int)(d.duracionDias - DbFunctions.DiffDays(d.fechaInicio, d.duracionEstimada)))),
             maxDiff          = g.Max(d => Math.Abs((int)(d.duracionDias - DbFunctions.DiffDays(d.fechaInicio, d.duracionEstimada)))),
             avgDuration      = (int)g.Average(d => d.duracionDias)
         };
         return(info.ToList());
     }
     else
     {
         IEnumerable <RequirementDurationsModel> info =
             from r in db.requerimientos
             group r by r.complejidad into g
             select new RequirementDurationsModel
         {
             complexity       = g.Select(d => d.complejidad).FirstOrDefault(),
             requirementCount = g.Count(),
             minDiff          = g.Min(d => Math.Abs((int)(d.duracionDias - DbFunctions.DiffDays(d.fechaInicio, d.duracionEstimada)))),
             maxDiff          = g.Max(d => Math.Abs((int)(d.duracionDias - DbFunctions.DiffDays(d.fechaInicio, d.duracionEstimada)))),
             avgDuration      = (int)g.Average(d => d.duracionDias)
         };
         return(info.ToList());
     }
 }
        public IList <ShoppingCart> GetShoppingCartNullOrThan30Days()
        {
            var query  = this.EntityDbSet.Include(p => p.ShoppingCartDetails);
            var result = query.Where(p => p.ShoppingCartDetails.Count() == 0 || DbFunctions.DiffDays(p.CreatedDate, DateTime.Now) < 10);

            return(result.ToList());
        }
 public IEnumerable <Appointment> GetDailyAppointments(DateTime getDate)
 {
     return(_db.Appointments.Where(a => DbFunctions.DiffDays(a.StartDateTime, getDate) == 0 && a.DStatus == true)
            .Include(m => m.Patient).OrderByDescending(m => m.StartDateTime)
            .Include(m => m.Doctor)
            .ToList());
 }
Esempio n. 14
0
        public JsonResult BuscarDatosBrowser()
        {
            var data = (from vehiculo in context.icb_vehiculo
                        join modelo in context.modelo_vehiculo
                        on vehiculo.modvh_id equals modelo.modvh_codigo
                        join color in context.color_vehiculo
                        on vehiculo.colvh_id equals color.colvh_id
                        join evento in context.icb_tpeventos
                        on vehiculo.id_evento equals evento.tpevento_id
                        where vehiculo.usado == true
                        select new
            {
                vehiculo.nummot_vh,
                modelo.modvh_nombre,
                color.colvh_nombre,
                placa = vehiculo.plac_vh,
                fecfact_fabrica = vehiculo.fecfact_fabrica.ToString(),
                anomodelo = vehiculo.anio_vh,
                vehiculo.plan_mayor,
                evento.tpevento_nombre,
                dias_inventario = DbFunctions.DiffDays(vehiculo.fecfact_fabrica, DateTime.Now)
            }).ToList().OrderByDescending(x => x.fecfact_fabrica);

            return(Json(data, JsonRequestBehavior.AllowGet));
        }
Esempio n. 15
0
        public HttpResponseMessage GetBurnedCalories(long date)
        {
            // Получаем смещение времени пользователя
            int timezoneOffset = RequestHelper.GetTimezoneOffset(Request);
            var zonedDateTime  = TimeHelper.ConvertFromUtc(TimeHelper.FromUnixMsToDateTime(date), timezoneOffset);
            var zonedDate      = zonedDateTime.Date;

            var workoutDiaryEntries = unitOfWork.WorkoutDiaryEntryRepository.Get(
                f => (f.CreateUserId == currentUserId &&
                      DbFunctions.DiffDays(
                          // Выбрасываем время, оставляем только дату
                          DbFunctions.TruncateTime(
                              // Добавляем смещение временной зоны пользователя, получаем время из БД в часовом формате пользователя
                              DbFunctions.AddMinutes(f.DateUTC, timezoneOffset)
                              ),
                          zonedDate) == 0),
                null,
                iE => iE.Exercise,
                iES => iES.Sets
                );

            decimal burnedCalories = 0;

            if (workoutDiaryEntries != null &&
                workoutDiaryEntries.Count() > 0)
            {
                burnedCalories = workoutDiaryEntries.Select(s => s.BurnedCalories).Sum();
            }

            return(Request.CreateResponse(HttpStatusCode.OK, Helpers.Utilities.RoundAFZ(burnedCalories)));
        }
Esempio n. 16
0
 IEnumerable <Randevu> IRandevuRepo.GunlukRandevulariGetir(DateTime tarihGetir)
 {
     return(_context.Randevular.Where(a => DbFunctions.DiffDays(a.BaslangicTarihSure, tarihGetir) == 0)
            .Include(p => p.Hasta)
            .Include(d => d.Doktor)
            .ToList());
 }
Esempio n. 17
0
        public HttpResponseMessage GetByDate(long date)
        {
            // Получаем смещение времени пользователя
            int timezoneOffset = RequestHelper.GetTimezoneOffset(Request);
            var zonedDateTime  = TimeHelper.ConvertFromUtc(TimeHelper.FromUnixMsToDateTime(date), timezoneOffset);
            var zonedDate      = zonedDateTime.Date;

            var workoutDiaryEntries = unitOfWork.WorkoutDiaryEntryRepository.Get(
                f => (f.CreateUserId == currentUserId &&
                      DbFunctions.DiffDays(
                          // Выбрасываем время, оставляем только дату
                          DbFunctions.TruncateTime(
                              // Добавляем смещение временной зоны пользователя, получаем время из БД в часовом формате пользователя
                              DbFunctions.AddMinutes(f.DateUTC, timezoneOffset)
                              ),
                          zonedDate) == 0),
                null,
                iE => iE.Exercise,
                iES => iES.Sets
                );

            // Преобразовываем в DTO-объект для ответа
            var workoutDiaryEntryDTO = Mapper.Map <IEnumerable <WorkoutDiaryEntryDTO> >(workoutDiaryEntries);

            return(Request.CreateResponse <IEnumerable <WorkoutDiaryEntryDTO> >(HttpStatusCode.OK, workoutDiaryEntryDTO));
        }
        public ActionResult dsCodeMoiHomNay(int?page)
        {
            ViewBag.Title = "Danh sách code mới hôm nay";
            IPagedList <CodeTable> codeTables = db.CodeTables.Where(t => DbFunctions.DiffDays(t.NgayDang, DateTime.Now) == 0).ToPagedList(page ?? 1, PAGE_SIZE);

            return(View("dsCode", codeTables));
        }
Esempio n. 19
0
 private IEnumerable <HistoryRanking> GetRankingSinceDate(BlogContext db, DateTime since, DateTime rankDate, HistoryRanking.Type type)
 {
     return(db.BlogRatings.Where(r => DbFunctions.DiffDays(since, r.ratetime) >= 0).GroupBy(r => r.BlogID)
            .Select(g => new { blogId = g.Key, rating = g.Sum(r => r.value) })
            .Join(
                db.Blogs.Where(b => b.isApproved == true && !NoRankCategories.Contains(b.CategoryID)),
                a => a.blogId,
                b => b.BlogID,
                (a, b) =>
                new
     {
         blog = b,
         a.rating,
         postCount = db.Posts.Count(p => p.IdType == ItemType.Blog && p.ItemId == b.BlogID)
     }
                ).OrderByDescending(r => r.rating)
            .ThenByDescending(r => r.blog.BlogDate)
            .Take(RankSize)
            .ToList().Select(r => new HistoryRanking
     {
         Author = r.blog.Author,
         BlogDate = r.blog.BlogDate,
         BlogID = r.blog.BlogID,
         BlogThumb = BlogHelper.firstImgPath(r.blog, true),
         BlogTitle = r.blog.BlogTitle,
         BlogVisit = r.blog.BlogVisit,
         PostCount = r.postCount,
         Rating = r.rating,
         RankType = type,
         RankDate = rankDate,
     }));
 }
Esempio n. 20
0
        public int RemoveCONSOLUNID()
        {
            int impactRows = 0;

            try
            {
                using (var ctx = new KEntities())
                {
                    var query = (from j in ctx.JOB
                                 where j.SUREFNO.Contains(SysConstants.K35_SYSTEM_ID) && j.OWNERID.StartsWith("CN") &&
                                 string.IsNullOrEmpty(j.VOIDBY) && j.SHPTYPE.Equals("H") &&
                                 string.IsNullOrEmpty(j.CONSOLNO) && j.CONSOLLOT_UNID != null

                                 && DbFunctions.DiffDays(j.UPDATEDATE ?? j.CREATEDATE, DateTime.Now) <= 150
                                 select j)
                                .Take(200)
                                .ToList()
                    ;

                    query.ForEach(q => {
                        q.CONSOLLOT_UNID         = null;
                        ctx.Entry <JOB>(q).State = System.Data.Entity.EntityState.Modified;
                    });

                    impactRows = ctx.SaveChanges();
                }
            }
            catch (System.ArgumentOutOfRangeException ex)
            {
                throw (ex);
            }

            return(impactRows);
        }
Esempio n. 21
0
 /// <summary>
 /// 构造函数
 /// </summary>
 public UserTableBLL()
 {
     TypeAdapterConfig <Models.UserTable, UserTableViewModel> .NewConfig()
     .Map(dest => dest.UserID, src => src.UserID)
     .Map(dest => dest.UserName, src => src.UserName)
     .Map(dest => dest.UserPassword, src => src.UserPassword)
     .Map(dest => dest.UserNickName, src => src.UserNickName)
     .Map(dest => dest.UserImage, src => src.UserImage)
     .Map(dest => dest.UserPhone, src => src.UserPhone)
     .Map(dest => dest.UserEmail, src => src.UserEmail)
     .Map(dest => dest.UserTheme, src => src.UserTheme)
     .Map(dest => dest.UserLevel, src => src.UserLevel)
     .Map(dest => dest.UserFrom, src => src.UserFrom)
     .Map(dest => dest.UserFromName, src => src.UserFromTable.UserFromName)
     .Map(dest => dest.ModifyDate, src => src.ModifyDate)
     .Map(dest => dest.CreateDate, src => src.CreateDate)
     .Map(dest => dest.UserCity, src => src.UserCity)
     .Map(dest => dest.UserMoney, src => src.UserMoney)
     .Map(dest => dest.UserWorkDay, src => src.UserWorkDay)
     .Map(dest => dest.UserWorkDayName, src => src.WorkDayTable.WorkDayName)
     .Map(dest => dest.UserFunction, src => src.UserFunction)
     .Map(dest => dest.CategoryRate, src => src.CategoryRate)
     .Map(dest => dest.Synchronize, src => src.Synchronize)
     .Map(dest => dest.MoneyStart, src => src.MoneyStart)
     .Map(dest => dest.IsUpdate, src => src.IsUpdate)
     .Map(dest => dest.ItemCount, src => src.ItemTable.Count())
     .Map(dest => dest.JoinDay, src => DbFunctions.DiffDays(src.CreateDate, DateTime.Now) + 1)
     .Compile();
 }
Esempio n. 22
0
        public int AddCONSOLUNID()
        {
            //Logger.Write();
            int impactRows = 0;

            using (var ctx = new KEntities())
            {
                var query = (from j in ctx.JOB
                             where j.SUREFNO.Contains(SysConstants.K35_SYSTEM_ID) && j.OWNERID.StartsWith("CN") &&
                             string.IsNullOrEmpty(j.VOIDBY) && j.SHPTYPE.Equals("H") &&
                             !string.IsNullOrEmpty(j.SHPNO) && !string.IsNullOrEmpty(j.CONSOLNO) && j.CONSOLLOT_UNID == null &&
                             ctx.JOB.Any(m => m.SHPNO == j.CONSOLNO && m.OWNERID.Equals(j.OWNERID) && m.BIZTYPE.Equals(j.BIZTYPE) &&
                                         string.IsNullOrEmpty(m.VOIDBY))

                             && DbFunctions.DiffDays(j.UPDATEDATE ?? j.CREATEDATE, DateTime.Now) <= 150
                             select j).ToList().Take(200);

                foreach (var q in query)
                {
                    var consol = ctx.JOB.Where(j => j.SHPNO.Equals(q.CONSOLNO) && j.OWNERID == q.OWNERID && j.VOIDBY == null & j.VOIDDATE == null)
                                 .ToList().FirstOrDefault();
                    if (consol != null)
                    {
                        q.CONSOLLOT_UNID         = consol.UNID;
                        ctx.Entry <JOB>(q).State = System.Data.Entity.EntityState.Modified;
                    }
                }
                impactRows = ctx.SaveChanges();
            }

            return(impactRows);
        }
Esempio n. 23
0
        public IList <PropuestaSolucion> ListarPropuestaSolucion(
            int?numero, string fechaRegistro, string dni, string nombre)
        {
            var query = _db.PropuestaSolucion.AsQueryable();

            if (numero.HasValue)
            {
                query = query.Where(x => x.Cod_Prop_Sol == numero.Value);
            }

            if (!string.IsNullOrWhiteSpace(fechaRegistro))
            {
                //query = query.Where(x => x.Fe_Creacion.ToShortDateString().Contains(fechaRegistro));
                DateTime vFechaRegistro = Convert.ToDateTime(fechaRegistro);
                query = query.Where(x => DbFunctions.DiffDays(x.Fec_Crea, vFechaRegistro).Value == 0);
            }

            if (!string.IsNullOrWhiteSpace(dni))
            {
                query = query.Where(x => x.Prospecto.Num_DNI == dni);
            }

            if (!string.IsNullOrWhiteSpace(nombre))
            {
                query = query.Where(x => x.Prospecto.Txt_Pros.Contains(nombre));
            }

            return(query.ToList());
        }
Esempio n. 24
0
 public object ObterPorLancamento()
 {
     return(contexto.Livros
            .Where(l => DbFunctions.DiffDays(l.DataPublicacao, DateTime.Now) <= 7)
            .Select(resumo)
            .ToList());
 }
Esempio n. 25
0
        public ActionResult RecentTransactionGridViewPartial([ModelBinder(typeof(DevExpressEditorsBinder))] int?year)
        {
            ViewBag.Year = year;
            var model = unitOfWork.TransactionsRepo.Fetch(m => DbFunctions.DiffDays(m.TransactionDate, DateTime.Now) <= 1).ToList();

            return(PartialView("_RecentTransactionGridViewPartial", model));
        }
        public void GenerateJsonFiles()
        {
            var db = new TravelAgencyDbContext();

            var allExcursion = db.Excursions
                               .Select(x => new
            {
                ID               = x.ExcursionId,
                Name             = x.Name,
                Duration         = (int)DbFunctions.DiffDays(x.StartDate, x.EndDate),
                Destination      = x.Destination.Country,
                ClientsCount     = x.Clients,
                TotalIncome      = x.PricePerClient * x.Clients,
                TransportCompany = x.Transport.CompanyName,
                TransportType    = x.Transport.Type.ToString(),
                GuideName        = x.Guide.Name
            }).ToList();

            foreach (var item in allExcursion)
            {
                var jsonObj = JsonConvert.SerializeObject(item, Formatting.Indented);
                var adress  = "../../../Data files/JSON/" + item.ID + ".json";
                File.WriteAllText(adress, jsonObj);
            }
        }
        /// <summary>
        /// 预约记录数据页
        /// </summary>
        /// <param name="search"></param>
        /// <returns></returns>
        public ActionResult ReservationList(SearchHelperModel search)
        {
            Expression <Func <Reservation, bool> > whereLambda = (m =>
                                                                  DbFunctions.DiffDays(DateTime.Today, m.ReservationForDate) <= 7 &&
                                                                  DbFunctions.DiffDays(DateTime.Today, m.ReservationForDate) >= 0);
            var rowsCount = 0;

            //补充查询条件
            //根据预约日期查询
            if (!String.IsNullOrEmpty(search.SearchItem0))
            {
                whereLambda = (m =>
                               DbFunctions.DiffDays(DateTime.Parse(search.SearchItem0), m.ReservationForDate) == 0);
            }
            //根据预约人联系方式查询
            if (!String.IsNullOrEmpty(search.SearchItem1))
            {
                whereLambda = (m => m.ReservationPersonPhone.Contains(search.SearchItem1));
            }
            //load data
            var list = new BLLReservation().GetReservationList(search.PageIndex, search.PageSize, out rowsCount,
                                                               whereLambda, m => m.ReservationForDate, m => m.ReservationTime, false, false);
            var dataList = list.ToPagedList(search.PageIndex, search.PageSize, rowsCount);

            return(View(dataList));
        }
        public void DbFunctionsTests_DiffDays_DateTime_Test()
        {
            DateTime testDateTime2 = this.TestDateTime.AddDays(1);
            var      result        = this.GetOrderQuery().Select(x => DbFunctions.DiffDays(this.TestDateTime, testDateTime2)).First();

            Assert.AreEqual(-1, result);
        }
Esempio n. 29
0
        /// <summary>
        /// 判断预约日期是否在可预约范围内
        /// </summary>
        /// <param name="dt">预约日期</param>
        /// <param name="isAdmin">isAdmin</param>
        /// <param name="msg">errMsg</param>
        /// <returns></returns>
        public static bool IsReservationForDateAvailabel(DateTime dt, bool isAdmin, out string msg)
        {
            var daysdiff = dt.Subtract(DateTime.Today).Days;

            if (daysdiff < 0)
            {
                msg = "预约日期不可预约";
                return(false);
            }
            if (!isAdmin && daysdiff > MaxReservationDiffDays)
            {
                msg = $"预约日期需要在{MaxReservationDiffDays}天内";
                return(false);
            }

            var disabledPeriods = new BLLDisabledPeriod().GetAll(p =>
                                                                 !p.IsDeleted && p.IsActive && DbFunctions.DiffDays(p.StartDate, dt) >= 0 &&
                                                                 DbFunctions.DiffDays(dt, p.EndDate) >= 0);

            if (disabledPeriods == null || !disabledPeriods.Any())
            {
                msg = "";
                return(true);
            }
            msg = "预约日期被禁用,如要预约请联系网站管理员";
            return(false);
        }
Esempio n. 30
0
        public void Execute()
        {
            var surveyCompletions = this.modelContext
                                    .SurveysCompletion
                                    .Include("Company")
                                    .Include("Role")
                                    .Where(x =>
                                           x.Role.Name == "OFERTA" &&
                                           x.PartialSave == true &&
                                           x.DeletedAt == null &&
                                           (
                                               (x.CompleteReminderSentAt == null || DbFunctions.DiffDays(x.CreatedAt, DateTime.Now) >= 10) ||
                                               (x.CompleteReminderSentAt != null && DbFunctions.DiffDays(x.CompleteReminderSentAt, DateTime.Now) >= 10))
                                           )
                                    .Take(20)
                                    .ToList();

            foreach (var surveyCompletion in surveyCompletions)
            {
                try
                {
                    var PdfName = this.pdfService.GetEvaluationFileName(surveyCompletion.Id);
                    this.supplyCompleteRegistrationReminderEmailService.Send(PdfName, surveyCompletion);
                }
                catch (Exception e)
                {
                }
                finally
                {
                    surveyCompletion.CompleteReminderSentAt = DateTime.Now;
                    this.modelContext.SaveChanges();
                }
            }
        }