예제 #1
0
        public IProgress <ProgressData> GetChildProgress(double weight = 1.0)
        {
            if (this.parent == null)
            {
                // If the parent is null, we return an instance of a progress but its results are always
                // swallowed (not used anywhere).
                return(new ChildProgress(weight));
            }

            if (weight <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(weight), "The weight must be greater than zero.");
            }

            if (this.hasReported && this.sealOnceStarted)
            {
                throw new InvalidOperationException("Cannot add a new progress after at least one of already added has reported anything.");
            }

            var progress = new ChildProgress(weight);

            this.childProgressElements.Add(progress);
            progress.ProgressChanged += this.OnProgressChanged;
            return(progress);
        }
예제 #2
0
        public static ChildProgress LoadSpecificChildProgressesByChildID(int progressID)
        {
            var entityProgress = new Domain.Entity.ChildProgress();
            var childProgress  = new ChildProgress();

            using (Domain.Repositories.ChildProgressRepository repo = new Domain.Repositories.ChildProgressRepository())
            {
                entityProgress = repo.LoadSpecificChildProgressesByprogressID(progressID);
            }
            childProgress = ConvertEntityToBusiness(entityProgress);
            return(childProgress);
        }
예제 #3
0
 public static Domain.Entity.ChildProgress ConvertBusinessToEntity(ChildProgress BProgress)
 {
     Domain.Entity.ChildProgress EProgress = new Domain.Entity.ChildProgress();
     try
     {
         EProgress.ChildID    = BProgress.ChildID;
         EProgress.ProgressID = BProgress.ProgressID;
         EProgress.Data       = Serialization.Serialize2(BProgress.Data);
         return(EProgress);
     }
     catch (Exception ex)
     {
         return(new Domain.Entity.ChildProgress());
     }
 }
예제 #4
0
        public static ChildProgress ConvertEntityToBusiness(Domain.Entity.ChildProgress EProg)
        {
            ChildProgress BProg = new ChildProgress();

            try
            {
                BProg.ProgressID = EProg.ProgressID;
                BProg.ChildID    = EProg.ChildID;
                BProg.Data       = Serialization.Deserialize2 <ChildProgress.ProgressData>(EProg.Data);
                return(BProg);
            }
            catch (Exception ex)
            {
                return(new ChildProgress());
            }
        }
        public int Save(ChildProgress progress)
        {
            try
            {
                Entity.ChildProgress temp = this.LearnHebrewDB.ChildProgresses.FirstOrDefault(x => x.ProgressID == progress.ProgressID);
                if (temp == null)
                {
                    this.LearnHebrewDB.ChildProgresses.Add(progress);
                }
                else
                {
                    this.LearnHebrewDB.Entry(temp).CurrentValues.SetValues(progress);
                }

                this.LearnHebrewDB.SaveChanges();

                return(progress.ProgressID);
            }
            catch (Exception ex)
            {
                return(0);
            }
        }