public static OpenETSyncHistoryDto AsDto(this OpenETSyncHistory openETSyncHistory)
 {
     return(new OpenETSyncHistoryDto()
     {
         OpenETSyncHistoryID = openETSyncHistory.OpenETSyncHistoryID,
         OpenETSyncResultType = openETSyncHistory.OpenETSyncResultType.AsDto(),
         WaterYear = openETSyncHistory.WaterYear.AsDto(),
         CreateDate = openETSyncHistory.CreateDate,
         UpdateDate = openETSyncHistory.UpdateDate
     });
 }
Exemplo n.º 2
0
        public static OpenETSyncHistoryDto New(RioDbContext dbContext, int year)
        {
            var openETSyncHistoryToAdd = new OpenETSyncHistory()
            {
                OpenETSyncResultTypeID = (int)OpenETSyncResultTypeEnum.InProgress,
                WaterYearID            = dbContext.WaterYear.Single(x => x.Year == year).WaterYearID,
                CreateDate             = DateTime.UtcNow,
                UpdateDate             = DateTime.UtcNow
            };

            dbContext.OpenETSyncHistory.Add(openETSyncHistoryToAdd);
            dbContext.SaveChanges();
            dbContext.Entry(openETSyncHistoryToAdd).Reload();

            return(GetByOpenETSyncHistoryID(dbContext, openETSyncHistoryToAdd.OpenETSyncHistoryID));
        }