using System; using System.Linq; using BO.AppServer.Data.Entity; using Quadarax.Foundation.Core.Data; using Quadarax.Foundation.Core.Data.Domain; using Quadarax.Foundation.Core.Data.Interface.Domain; using Quadarax.Foundation.Core.Data.Repository; namespace BO.AppServer.Data.Repository { public class StatisticRepo : EntityRepository { public StatisticRepo(IUnitOfWork unitOfWork) : base(unitOfWork) { } public Statistic GetCurrent() { var timestamp = DateTime.Now; var current = Query(Paging.NoPaging()) .FirstOrDefault(x => x.Day == timestamp.Day && x.Month == timestamp.Month && x.Year == timestamp.Year); if (current != null) return current; current = New(); current.Day = timestamp.Day; current.Month = timestamp.Month; current.Year = timestamp.Year; current.Created = DateTime.Now; Set(current); Commit(); return current; } } }