Ejemplo n.º 1
0
 public static SuplementDTO SaveSuplement(SuplementDTO suplementDto)
 {
     return(exceptionHandling(delegate
     {
         return Instance.SaveSuplement(Token, suplementDto);
     }));
 }
Ejemplo n.º 2
0
        public SuplementDTO SaveSuplement(Token token, SuplementDTO suplement)
        {
            var securityInfo = SecurityManager.EnsureAuthentication(token);
            var service      = new SupplementService(Session, securityInfo, Configuration);

            return(service.SaveSuplement(suplement));
        }
Ejemplo n.º 3
0
        public SuplementDTO SaveSuplement(SuplementDTO suplement)
        {
            var dbExercise = Mapper.Map <SuplementDTO, Suplement>(suplement);
            var session    = Session;

            using (var tx = session.BeginSaveTransaction())
            {
                Suplement dbSuplement;
                if (dbExercise.IsNew)
                {
                    dbExercise.CreationDate = Configuration.TimerService.UtcNow;
                    dbSuplement             = dbExercise;
                }
                else
                {
                    dbSuplement = session.Get <Suplement>(suplement.GlobalId);
                }

                if (dbSuplement.Profile == null)
                {
                    throw new CrossProfileOperationException("Cannot change default suplement");
                }
                if (dbSuplement.Profile.GlobalId != suplement.ProfileId || suplement.ProfileId != SecurityInfo.SessionData.Profile.GlobalId)
                {
                    throw new CrossProfileOperationException("Cannot  change an suplement for another profile");
                }

                dbExercise = (Suplement)session.Merge(dbExercise);
                tx.Commit();
            }
            return(Mapper.Map <Suplement, SuplementDTO>(dbExercise));
        }
Ejemplo n.º 4
0
        void viewSuplement(SuplementDTO suplement)
        {
            SuplementTypeEditor dlg = new SuplementTypeEditor();

            dlg.Fill(suplement);
            if (dlg.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
            {
                Fill();
            }
        }
Ejemplo n.º 5
0
        public void Fill(SuplementDTO suplement)
        {
            bool isReadOnly = suplement.ProfileId == null && !suplement.IsNew;

            this.suplement  = suplement;
            txtName.Text    = suplement.Name;
            txtComment.Text = suplement.Comment;

            setReadOnly(isReadOnly);
        }
 protected SupplementCycleDosageDTO CreateDosage(decimal dosageValue, SuplementDTO supplement, SupplementCycleDayRepetitions repetitions = SupplementCycleDayRepetitions.OnceAWeek, Service.V2.Model.DosageType dosageType = Service.V2.Model.DosageType.MiliGrams, Service.V2.Model.TimeType timeType = Service.V2.Model.TimeType.NotSet)
 {
     var dosage = new SupplementCycleDosageDTO();
     dosage.Dosage = dosageValue;
     dosage.DosageType = dosageType;
     dosage.Repetitions = repetitions;
     dosage.Supplement = supplement;
     dosage.TimeType =  timeType;
     return dosage;
 }
Ejemplo n.º 7
0
 void viewSuplement(SuplementDTO suplement)
 {
     //TODO:FINISH
     //SuplementTypeEditor dlg = new SuplementTypeEditor();
     //dlg.Fill(suplement);
     //if (dlg.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
     //{
     //    Fill();
     //}
 }
Ejemplo n.º 8
0
        public static string GetFirstNameKey(SuplementDTO suplement)
        {
            char key = char.ToLower(suplement.Name[0]);

            if (key < 'a' || key > 'z')
            {
                key = '#';
            }

            return(key.ToString());
        }
Ejemplo n.º 9
0
        public override void BuildDatabase()
        {
            using (var tx = Session.BeginTransaction())
            {
                profiles.Clear();
                profiles.Add(CreateProfile(Session, "test1"));

                metenolon = CreateSupplement("Metenolon Enantat").Map <SuplementDTO>();
                tx.Commit();
            }
        }
Ejemplo n.º 10
0
        public override void BuildDatabase()
        {
            using (var tx = Session.BeginTransaction())
            {
                profiles.Clear();
                profiles.Add(CreateProfile(Session, "test1"));

                storm = CreateSupplement("Storm").Map <SuplementDTO>();
                shock = CreateSupplement("ShockTherapy").Map <SuplementDTO>();
                tx.Commit();
            }
        }
Ejemplo n.º 11
0
        public override void BuildDatabase()
        {
            using (var tx = Session.BeginTransaction())
            {
                profiles.Clear();
                profiles.Add(CreateProfile(Session, "test1"));

                stanozolol  = CreateSupplement("Stanozolol").Map <SuplementDTO>();
                trenbolon   = CreateSupplement("Trenbolon Acetat").Map <SuplementDTO>();
                testosteron = CreateSupplement("Testosteron Propionat").Map <SuplementDTO>();
                tx.Commit();
            }
        }
Ejemplo n.º 12
0
        public SupplementItemViewModel AddSupplementItem(SuplementDTO supplement = null)
        {
            var item = new SuplementItemDTO();

            item.Suplement       = supplement;
            item.Time.DateTime   = DateTime.Now;
            item.SuplementsEntry = Entry;
            Entry.Items.Add(item);
            var viewModel = new SupplementItemViewModel(item);

            _supplements.Add(viewModel);
            return(viewModel);
        }
        private SupplementCycleDefinitionDTO createCycleForRepetitions2()
        {
            SuplementDTO supple = new SuplementDTO();
            var cycleDefinition = new SupplementCycleDefinitionDTO();
            cycleDefinition.Name = "sterydy";
            cycleDefinition.Language = "en";
            var week = new SupplementCycleWeekDTO();
            week.Name = "Training week1";
            week.CycleWeekStart = 1;
            week.CycleWeekEnd = 2;
            week.IsRepetitable = false;
            cycleDefinition.Weeks.Add(week);
            var dosage = CreateDosage(400, supple);
            week.Dosages.Add(dosage);
            dosage = CreateDosage(750, supple);
            week.Dosages.Add(dosage);

            week = new SupplementCycleWeekDTO();
            week.Name = "Training week2";
            week.CycleWeekStart = 3;
            week.CycleWeekEnd = 4;
            week.IsRepetitable = false;
            cycleDefinition.Weeks.Add(week);
            dosage = CreateDosage(400, supple);
            week.Dosages.Add(dosage);
            dosage = CreateDosage(750, supple);
            week.Dosages.Add(dosage);

            week = new SupplementCycleWeekDTO();
            week.Name = "Training week3";
            week.CycleWeekStart = 5;
            week.CycleWeekEnd = 6;
            cycleDefinition.Weeks.Add(week);
            dosage = CreateDosage(300, supple);
            week.Dosages.Add(dosage);
            dosage = CreateDosage(700, supple);
            week.Dosages.Add(dosage);

            week = new SupplementCycleWeekDTO();
            week.Name = "Training week4";
            week.CycleWeekStart = 7;
            week.CycleWeekEnd = 7;
            cycleDefinition.Weeks.Add(week);
            dosage = CreateDosage(410, supple);
            week.Dosages.Add(dosage);
            dosage = CreateDosage(650, supple);
            week.Dosages.Add(dosage);


            return cycleDefinition;
        }
Ejemplo n.º 14
0
        public override void BuildDatabase()
        {
            using (var tx = Session.BeginTransaction())
            {
                profiles.Clear();
                profiles.Add(CreateProfile(Session, "test1"));

                nandrolon   = CreateSupplement("Nandrolon Decanoat").Map <SuplementDTO>();
                testosteron = CreateSupplement("Testosteron Enantat").Map <SuplementDTO>();
                metandienon = CreateSupplement("Metandienon").Map <SuplementDTO>();
                hormon      = CreateSupplement("Hormon wzrostu").Map <SuplementDTO>();
                tx.Commit();
            }
        }
Ejemplo n.º 15
0
        public override void BuildDatabase()
        {
            using (var tx = Session.BeginTransaction())
            {
                profiles.Clear();
                profiles.Add(CreateProfile(Session, "test1"));

                hcg       = CreateSupplement("HCG").Map <SuplementDTO>();
                clomifen  = CreateSupplement("Clomifen").Map <SuplementDTO>();
                kreatyna  = CreateSupplement("Kreatyna").Map <SuplementDTO>();
                efedryna  = CreateSupplement("Efedryna").Map <SuplementDTO>();
                witaminaC = CreateSupplement("Witamina C").Map <SuplementDTO>();
                tx.Commit();
            }
        }
        private List <SupplementCycleDosageDTO> getDosage(SuplementDTO suplementDTO, string name, int weekNumber)
        {
            List <SupplementCycleDosageDTO> dosages = new List <SupplementCycleDosageDTO>();

            foreach (var week in definition.Weeks)
            {
                if (weekNumber >= week.CycleWeekStart && weekNumber <= week.CycleWeekEnd)
                {
                    foreach (var dosage in week.Dosages.OfType <SupplementCycleDosageDTO>())
                    {
                        if (dosage.Supplement.GlobalId == suplementDTO.GlobalId && dosage.Name == name)
                        {
                            dosages.Add(dosage);
                        }
                    }
                }
            }
            return(dosages);
        }
Ejemplo n.º 17
0
 public SuplementDTO SaveSuplement(Token token, SuplementDTO suplement)
 {
     throw new NotImplementedException();
 }
 public SuplementDTO SaveSuplement(Token token, SuplementDTO suplement)
 {
     return(exceptionHandling(token, () => InternalService.SaveSuplement(token, suplement)));
 }