Example #1
0
 public static DtoFulfillmentArchive From(FulfillmentArchive archive)
 {
     return(new DtoFulfillmentArchive()
     {
         ParentUid = archive.ParentUid,
         Uid = archive.Uid,
         Remark = archive.Remark,
         Time = archive.Time,
         IsDeleted = archive.IsDeleted,
         DeleteReason = archive.DeleteReason
     });
 }
Example #2
0
        public static DtoRoutine From(RoutineFulfillment fulfill, bool includeHistory)
        {
            var history = includeHistory ? fulfill.StagedArchives?.Select(h => DtoFulfillmentArchive.From(h))?.ToArray() : null;
            FulfillmentArchive lastFulfill = null;

            if (fulfill.StagedArchives?.Length > 0)
            {
                for (int i = fulfill.StagedArchives.Length - 1; i >= 0; i--)
                {
                    if (fulfill.StagedArchives[i].IsDeleted == null || !fulfill.StagedArchives[i].IsDeleted.Value)
                    {
                        lastFulfill = fulfill.StagedArchives[i];
                        break;
                    }
                }
            }

            if (lastFulfill == null && fulfill.HasArchived)
            {
                //fixme, read from archive file, do this outside this method
                //also change front end logic once do it, get lastFulfill directly instead of search among staged items?
                //  - exception when user just delete a history item and we want to repaint UI
                //    may also return last fulfill id ? so we can tall if last fulfill still valid after the delete
            }

            return(new DtoRoutine()
            {
                Uid = fulfill.Uid,
                Name = fulfill.Name,
                LastFulfill = lastFulfill?.Time,
                LastRemark = lastFulfill?.Remark,
                HistoryFulfillments = history,
                HasArchived = fulfill.HasArchived,
                EnableSchedule = fulfill.EnableSchedule,
                RecursiveIntervalDays = fulfill.RecursiveIntervalDays,
                CreateAt = fulfill.CreateAt,
                CreateBy = fulfill.CreateBy,
                IsDeleted = fulfill.IsDeleted,
                DeleteReason = fulfill.DeleteReason
            });
        }