Inheritance: BaseModel
        public List <ChildModel> GetLeadersBySteps()
        {
            List <ChildModel> childList = new List <ChildModel>();

            try
            {
                using (SqlConnection conn = new SqlConnection(connectionString))
                {
                    conn.Open();
                    SqlCommand    cmd    = new SqlCommand(SQL_GetLeadersBySteps, conn);
                    SqlDataReader reader = cmd.ExecuteReader();

                    while (reader.Read())
                    {
                        ChildModel child = new ChildModel()
                        {
                            Seconds  = Convert.ToInt32(reader["seconds"]),
                            Carrots  = Convert.ToInt32(reader["carrots"]),
                            UserName = Convert.ToString(reader["username"]),
                        };
                        childList.Add(child);
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(childList);
        }
        public void NameTest2()
        {
            var model = new ChildModel();

            model.Name.Value = "AAああ";
            model.IsValid.Value.IsFalse();
        }
        public List <ChildModel> GetChildren(int parent_Id)
        {
            List <ChildModel> children = new List <ChildModel>();

            try
            {
                using (SqlConnection conn = new SqlConnection(connectionString))
                {
                    conn.Open();
                    SqlCommand cmd = new SqlCommand(SQL_GetChildren, conn);
                    cmd.Parameters.AddWithValue("@parent_id", parent_Id);

                    SqlDataReader reader = cmd.ExecuteReader();

                    while (reader.Read())
                    {
                        ChildModel child = new ChildModel
                        {
                            Child_Id   = Convert.ToInt32(reader["child_id"]),
                            First_Name = Convert.ToString(reader["first_name"]),
                            UserName   = Convert.ToString(reader["username"]),
                            Seconds    = Convert.ToInt32(reader["seconds"]),
                            Carrots    = Convert.ToInt32(reader["carrots"]),
                        };
                        children.Add(child);
                    }
                }
            }
            catch (SqlException e)
            {
                throw;
            }
            return(children);
        }
        public ActionResult Closet(ChildModel model)
        {
            // check if logged in
            if (Session["child"] == null)
            {
                return(View("Login"));
            }

            ChildModel child = Session["child"] as ChildModel;

            if (model.Mascot.CurrentHat != null)
            {
                mascotDAL.UpdateHat(child.Mascot.Mascot_Id, model.Mascot.CurrentHat);
            }

            if (model.Mascot.CurrentBackground != null)
            {
                mascotDAL.UpdateBackground(child.Mascot.Mascot_Id, model.Mascot.CurrentBackground);
            }

            child.Mascot     = mascotDAL.GetMascot(child);
            Session["child"] = child;

            return(RedirectToAction("Closet"));
        }
        public ActionResult Store()
        {
            // check if logged in
            if (Session["child"] == null)
            {
                return(View("Login"));
            }

            ChildModel child = Session["child"] as ChildModel;

            // check if child needs to create mascot
            if (child.Mascot == null)
            {
                return(RedirectToAction("ChooseMascot"));
            }

            StoreViewModel viewModel = new StoreViewModel();

            viewModel.Mascot = child.Mascot;

            viewModel.Hats        = itemsDAL.GetHats();
            viewModel.Backgrounds = itemsDAL.GetBackgrounds();

            Session["storeModel"] = viewModel;

            return(View("Store", viewModel));
        }
        public void NameTest()
        {
            var model = new ChildModel();

            model.Name.Value = "AA00";
            model.IsValid.Value.IsTrue();
        }
        public void NameTest3()
        {
            var model = new ChildModel();

            model.Name.Value = null;
            model.IsValid.Value.IsFalse();
        }
        public ActionResult AddActivity(string userName)
        {
            // check if logged in
            if (Session["parent"] == null)
            {
                return(View("Login"));
            }

            ChildModel child = childDAL.GetChild(userName);

            child.Mascot = mascotDAL.GetMascot(child);


            AddActivityViewModel activityViewModel = new AddActivityViewModel();

            activityViewModel.UserName = userName;
            activityViewModel.Child_Id = child.Child_Id;
            activityViewModel.Mascot   = child.Mascot;

            if (TempData["CustomError"] != null)
            {
                ModelState.AddModelError("futureDate", TempData["CustomError"].ToString());
            }

            return(View("AddActivity", activityViewModel));
        }
Example #9
0
        private IEnumerable <ChildModel> GetChildren(Guid parentId)
        {
            var children = new List <ChildModel>();

            try
            {
                var credentials = new Credentials
                {
                    UserName = _configuration.SourceUserName,
                    Password = _configuration.SourcePassword
                };

                var results       = _service.GetChildren(parentId.ToString().ToUpper(), _configuration.SourceDatabase, credentials);
                var childElements = results.XPathSelectElements("//item");

                foreach (var childElement in childElements)
                {
                    var child = new ChildModel
                    {
                        HasChildren = int.Parse(childElement.Attribute("haschildren").Value) == 1,
                        Id          = Guid.Parse(childElement.Attribute("id").Value),
                        Name        = childElement.Value,
                        ParentId    = parentId,
                        TemplateId  = Guid.Parse(childElement.Attribute("templateid").Value)
                    };

                    children.Add(child);
                }
            }
            catch (Exception ex)
            {
                Sitecore.Diagnostics.Log.Error(string.Format("[FieldMigrator] (HardRockWebServiceProxy) GetChildren ParentId: {0}", parentId), ex, this);
            }
            return(children);
        }
Example #10
0
        public void RegistredChild(ChildModel model, string login)
        {
            Child child = new Child()
            {
                FirstName   = model.FirstName,
                LastName    = model.LastName,
                MiddleName  = model.MiddleName,
                DateOfBirth = model.DateOfBirth,
                Address     = new Address()
                {
                    City      = model.City,
                    House     = model.House,
                    Street    = model.Street,
                    Apartment = model.Apartment
                },
                BirthCertificate = new BirthCertificate()
                {
                    Number      = model.Number,
                    Description = model.Description,
                    Series      = model.Series
                },
            };

            _childRepository.AddChild(child, login, model.KindergartenNumber);
        }
Example #11
0
        /// <summary>
        /// get from database by childID
        /// </summary>
        /// <param name="childID"></param>
        /// <returns></returns>
        public static ChildModel GetChildByID(int childID)
        {
            ChildModel childModel = null;
            try
            {
                using (DBEntities DB = new DBEntities())
                {
                    var query = from c in DB.Child
                                where (c.ChildID == childID)
                                select new ChildModel()
                                {
                                   
                                    ChildName = c.ChildName,
                                    DateOfBirth = c.DateOfBirth,
                                    Gender = c.Gender,
                                    CreatedBy = c.CreatedBy,
                                    Created = c.Created,
                                    ModifiedBy = c.ModifiedBy,
                                    Modified = c.Modified
                                };

                    childModel = query.FirstOrDefault();
                }
            }
            catch (Exception ex)
            {
              //log exception
            }
            return childModel;
        }
        public MascotModel GetMascot(ChildModel child)
        {
            MascotModel mascot = null;

            try
            {
                using (SqlConnection conn = new SqlConnection(connectionString))
                {
                    conn.Open();
                    SqlCommand cmd = new SqlCommand(SQL_GetMascot, conn);
                    cmd.Parameters.AddWithValue("@child_id", child.Child_Id);

                    SqlDataReader reader = cmd.ExecuteReader();

                    while (reader.Read())
                    {
                        mascot = new MascotModel
                        {
                            Mascot_Id         = Convert.ToInt32(reader["mascot_id"]),
                            Mascot_Image      = Convert.ToString(reader["mascot_image"]),
                            Child_Id          = Convert.ToInt32(reader["child_id"]),
                            CurrentHat        = Convert.ToString(reader["current_hat"]),
                            CurrentBackground = Convert.ToString(reader["current_background"]),
                            BaseballHat       = Convert.ToBoolean(reader["baseball_hat"]),
                            Beanie            = Convert.ToBoolean(reader["beanie"]),
                            Bonnet            = Convert.ToBoolean(reader["bonnet"]),
                            Bow          = Convert.ToBoolean(reader["bow"]),
                            BucketHat    = Convert.ToBoolean(reader["bucket_hat"]),
                            Crown        = Convert.ToBoolean(reader["crown"]),
                            FlowerCrown  = Convert.ToBoolean(reader["flower_crown"]),
                            PropellerHat = Convert.ToBoolean(reader["propeller_hat"]),
                            Sombrero     = Convert.ToBoolean(reader["sombrero"]),
                            TopHat       = Convert.ToBoolean(reader["top_hat"]),
                            Beach        = Convert.ToBoolean(reader["beach"]),
                            City         = Convert.ToBoolean(reader["city"]),
                            Desert       = Convert.ToBoolean(reader["desert"]),
                            Forest       = Convert.ToBoolean(reader["forest"]),
                            Mountain     = Convert.ToBoolean(reader["mountain"]),
                            Ocean        = Convert.ToBoolean(reader["ocean"]),
                        };

                        if (mascot.CurrentHat == "")
                        {
                            mascot.CurrentHat = null;
                        }

                        if (mascot.CurrentBackground == "")
                        {
                            mascot.CurrentBackground = null;
                        }
                    }
                    return(mascot);
                }
            }
            catch (SqlException e)
            {
                throw;
            }
        }
Example #13
0
 public void PostMethodWithUrlcode(ChildModel childModel)
 {
     json.Obj = new
     {
         name = childModel.name,
         age  = childModel.age
     };
 }
Example #14
0
 private void GetgartenNumber()
 {
     _childModel         = new ChildModel();
     _kindergartenNumber = new List <int>();
     foreach (var garten in KindergartensModels)
     {
         _kindergartenNumber.Add(garten.Number);
     }
 }
        public AddVaccineViewModel(ChildModel _child)
        {
            // Property
            Child   = _child;
            Vaccine = new VaccineModel();


            // Command
            PostCommand = new Command(Post);
        }
Example #16
0
        public void Delete(ChildModel _childModel)
        {
            using (_childRepository = new ChildRepository())
            {
                Child child = (_childRepository.FindBy(child1 => child1.Id == 1)).First();

                _childRepository.Delete(child);
                _childRepository.Save();
            }
        }
        private ChildModel AddChild(string name)
        {
            ChildModel child;

            _model.Children.Add(child = new ChildModel()
            {
                Name = { Value = name }
            });

            return(child);
        }
        public ActionResult AddCarrot(string userName)
        {
            childDAL.AddCarrot(userName);

            ChildModel child = childDAL.GetChild(userName);

            child.Mascot     = mascotDAL.GetMascot(child);
            Session["child"] = child;

            return(null);
        }
        public void AggregateChild_GetParent_Succeeds()
        {
            // arrange
            var sut = new ChildModel();

            // act
            sut.SetParent(new RootModel());

            // assert
            sut.GetParent().Should().NotBeNull();
        }
        public void AggregateChild_AddEvent_Throws_Exception()
        {
            // arrange
            var sut = new ChildModel();

            // act
            Action act = () => sut.AddEvent(new SomeEvent(new RootModel()));

            // assert
            act.Should().Throw <InvalidOperationException>();
        }
        public void FillChildDataGrid(IEnumerable <Child> childs)
        {
            GrBChildren.IsEnabled = true;
            // Wenn das Datagrid nicht leer ist, müssen zunächst alle Zeilen gelöscht werden.
            // Folgedessen müssen soviele Zeilen erstellt werden wie es Kinder gibt!

            if (this._Childs.Count > 0)
            {
                this._Childs.Clear();
            }

            //Combobox belegen
            CBItem male = new CBItem();

            male.Name = "Männlich";
            CBItem female = new CBItem();

            female.Name = "Weiblich";


            if (!(childs.Count() == 0))
            {
                foreach (Child child in childs)
                {
                    List <CBItem> existingGenderTypes = new List <CBItem>();
                    if (child.IsFemale)
                    {
                        existingGenderTypes.Add(female);
                        existingGenderTypes.Add(male);
                    }
                    else
                    {
                        existingGenderTypes.Add(male);
                        existingGenderTypes.Add(female);
                    }


                    ChildModel existingChild = new ChildModel();
                    existingChild.genderType = existingGenderTypes;
                    existingChild.ChildID    = child.ChildID;
                    existingChild.FirstName  = child.FirstName;
                    existingChild.LastName   = child.LastName;
                    existingChild.Birthday   = child.DateOfBirth;
                    existingChild.IsFemale   = child.IsFemale;
                    existingChild.isAdded    = true;
                    this._Childs.Add(existingChild);
                }
            }

            dtgChildren.Items.Refresh();
            dtgChildren.ItemsSource = this._Childs;
            dtgChildren.Items.Refresh();
            addNewChildtoDatagrid();
        }
Example #22
0
        public IActionResult Index(ChildModel c)
        {
            if (ModelState.IsValid)
            {
                CurrentUser.User = new ChildModel(c.Nickname);


                return(RedirectToAction("Detail"));
            }
            return(View());
        }
        // ctor
        public AddChildViewModel(FamilyModel family)
        {
            // Objects
            ChildValidator = new ChildValidator();
            Family         = family;

            // Property
            Child = new ChildModel();

            // Command
            PutCommand = new Command(Post);
        }
        public ActionResult Dashboard()
        {
            // check if logged in
            if (Session["child"] == null)
            {
                return(View("Login"));
            }

            ChildModel child = Session["child"] as ChildModel;

            return(View("Dashboard", child));
        }
Example #25
0
        public EditChildViewModel(ChildModel child, Guid familyId)
        {
            // Objects
            ChildValidator = new ChildValidator();

            // Property
            FamilyId = familyId;
            Child    = child;

            // Command
            PutCommand = new Command(Put);
        }
        public ActionResult Store(StoreViewModel storeModel)
        {
            // check if logged in
            if (Session["child"] == null)
            {
                return(View("Login"));
            }

            ChildModel child = Session["child"] as ChildModel;

            // check if child needs to create mascot
            if (child.Mascot == null)
            {
                return(RedirectToAction("ChooseMascot"));
            }

            StoreViewModel sessionModel = Session["storeModel"] as StoreViewModel;

            storeModel.Hats        = sessionModel.Hats;
            storeModel.Mascot      = sessionModel.Mascot;
            storeModel.Backgrounds = sessionModel.Backgrounds;

            // validation redirect
            if (!ModelState.IsValid)
            {
                return(View("Store"));
            }

            ItemModel purchasedItem = itemsDAL.GetItem(storeModel.ItemId);

            if (purchasedItem.Price > child.Carrots)
            {
                ModelState.AddModelError("insufficient-carrots", "You do not have enough carrots to purchase that item.");
                return(View("Store", storeModel));
            }

            child.Mascot.OwnedItems = mascotDAL.GetListOfItems(child.Child_Id);

            if (child.Mascot.OwnedItems.Contains(purchasedItem.Item_Id))
            {
                ModelState.AddModelError("item-already-purchased", "You aready own this item!");
                return(View("Store", storeModel));
            }

            mascotDAL.PurchaseItem(child.Child_Id, purchasedItem.Image, purchasedItem.Price);

            child            = childDAL.GetChild(child.UserName);
            child.Mascot     = mascotDAL.GetMascot(child);
            Session["child"] = child;

            return(RedirectToAction("Closet", child));
        }
        public ActionResult ActivityHistory(int child_Id, string userName)
        {
            // check if logged in
            if (Session["parent"] == null)
            {
                return(View("Login"));
            }

            ChildModel child = childDAL.GetChild(userName);

            child.Activities = activityDAL.GetActivities(child_Id);
            return(View("ActivityHistory", child));
        }
        public void addNewChildtoDatagrid()
        {
            GrBChildren.IsEnabled = true;

            //Combobox belegen
            CBItem male = new CBItem();

            male.Name = "Männlich";
            CBItem female = new CBItem();

            female.Name = "Weiblich";
            List <CBItem> newGenderTypes = new List <CBItem>();

            newGenderTypes.Add(male);
            newGenderTypes.Add(female);

            if (_Childs.Count == 0)
            {
                //Hinzufügen eines Kindes ermöglichen
                ChildModel newChild = new ChildModel();
                newChild.genderType = newGenderTypes;
                newChild.ChildID    = 0;
                newChild.FirstName  = "";
                newChild.LastName   = _currentPerson.LastName;
                newChild.Birthday   = DateTime.Now;
                newChild.IsFemale   = false;
                newChild.isAdded    = false;
                this._Childs.Add(newChild);
            }
            else
            {
                //Prüfung ob alle zum Speichern vorgemerkt sind Nur dann Neue Zeile
                if (_Childs.Last().isAdded == true)
                {
                    //Hinzufügen eines Kindes ermöglichen
                    ChildModel newChild = new ChildModel();
                    newChild.genderType = newGenderTypes;
                    newChild.ChildID    = 0;
                    newChild.FirstName  = "";
                    newChild.LastName   = _currentPerson.LastName;
                    newChild.Birthday   = DateTime.Now;
                    newChild.IsFemale   = false;
                    newChild.isAdded    = false;
                    this._Childs.Add(newChild);
                }
            }

            dtgChildren.Items.Refresh();
            dtgChildren.ItemsSource = this._Childs;
            dtgChildren.Items.Refresh();
        }
        public void Can_save_child_to_parent_when_entity_state_changed()
        {
            var child  = new ChildModel();
            var parent = new ParentModel();

            child.Parent = parent;

            Db.Entry(child).State = EntityState.Added;

            Db.SaveChanges();

            child.Id.AssertIsNotZero();
            parent.Id.AssertIsNotZero();
        }
        public void Can_save_child_to_parent()
        {
            var child  = new ChildModel();
            var parent = new ParentModel();

            child.Parent = parent;

            Db.Children.Add(child);

            Db.SaveChanges();

            child.Id.AssertIsNotZero();
            parent.Id.AssertIsNotZero();
        }