Exemplo n.º 1
0
        public async Task <IActionResult> Create(PersonalInfoInputModel input)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.View(input));
            }

            await this.personalInfosService.AddAsync(input);

            return(this.RedirectToAction("AllPerSchool", "Children", new { area = string.Empty }));
        }
Exemplo n.º 2
0
        public IActionResult Create()
        {
            var viewModel        = new PersonalInfoInputModel();
            var userName         = this.User.Identity.Name;
            var currentPrincipal = this.principalsRepository.AllAsNoTracking()
                                   .FirstOrDefault(x => x.User.UserName == userName);
            var schoolId = currentPrincipal.NurserySchoolId;

            viewModel.ChildrenItems = this.childrenService.GetAllAsKeyValuePairsPerSchool(schoolId);

            return(this.View(viewModel));
        }
        public async Task AddAsync(PersonalInfoInputModel input)
        {
            var personalInfo = new PersonalInfo
            {
                Height  = input.Height,
                Weight  = input.Weight,
                ChildId = int.Parse(input.Child),
            };

            await this.personalInfosRepository.AddAsync(personalInfo);

            await this.personalInfosRepository.SaveChangesAsync();
        }
Exemplo n.º 4
0
        public async Task <IActionResult> Edit(int id, PersonalInfoInputModel input)
        {
            var currentPersonalInfo = this.personalInfosRepository.AllAsNoTracking()
                                      .FirstOrDefault(x => x.ChildId == id);

            var personalInfo = new PersonalInfo
            {
                Id         = currentPersonalInfo.Id,
                Height     = input.Height,
                Weight     = input.Weight,
                ChildId    = currentPersonalInfo.ChildId,
                IsDeleted  = currentPersonalInfo.IsDeleted,
                DeletedOn  = currentPersonalInfo.DeletedOn,
                CreatedOn  = currentPersonalInfo.CreatedOn,
                ModifiedOn = input.ModifiedOn,
            };

            if (id != personalInfo.ChildId)
            {
                return(this.NotFound());
            }

            if (this.ModelState.IsValid)
            {
                try
                {
                    this.personalInfosRepository.Update(personalInfo);
                    await this.personalInfosRepository.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!this.PersonalInfoExists(personalInfo.Id))
                    {
                        return(this.NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }

                return(this.RedirectToAction("AllPerSchool", "Children", new { area = string.Empty }));
            }

            return(this.View(personalInfo));
        }
        public async Task <IActionResult> OnGet(string statusMessage = null)
        {
            Positions = await _context.Positions.Where(p => p.Name != "All").ToListAsync();

            var currentUser = await _userManager.GetUserAsync(User);

            await _context.Entry(currentUser).Reference(p => p.VolunteerProfile).LoadAsync();

            await _context.Entry(currentUser.VolunteerProfile).Collection(p => p.Positions).LoadAsync();

            LoggedInUser = currentUser.VolunteerProfile.FirstName + " " + currentUser.VolunteerProfile.LastName;
            PersonalInfo = new PersonalInfoInputModel()
            {
                Address               = currentUser.VolunteerProfile.Address,
                City                  = currentUser.VolunteerProfile.City,
                PostalCode            = currentUser.VolunteerProfile.PostalCode,
                Email                 = currentUser.Email,
                MainPhone             = currentUser.VolunteerProfile.MainPhone,
                AlternatePhone1       = currentUser.VolunteerProfile.AlternatePhone1,
                AlternatePhone2       = currentUser.VolunteerProfile.AlternatePhone2,
                EmergencyName         = currentUser.VolunteerProfile.EmergencyFullName,
                EmergencyRelationship = currentUser.VolunteerProfile.EmergencyRelationship,
                EmergencyPhone1       = currentUser.VolunteerProfile.EmergencyPhone1,
                EmergencyPhone2       = currentUser.VolunteerProfile.EmergencyPhone2,
                Positions             = currentUser.VolunteerProfile.Positions.ToList(),
                FirstAidCpr           = currentUser.VolunteerProfile.FirstAidCpr,
                FirstAidCprExpiry     = currentUser.VolunteerProfile.FirstAidCprExpiry,
                FirstAidCprLevel      = currentUser.VolunteerProfile.FirstAidCprLevel,
                FoodSafe              = currentUser.VolunteerProfile.FoodSafe,
                FoodSafeExpiry        = currentUser.VolunteerProfile.FoodSafeExpiry,
                OtherCertificates     = currentUser.VolunteerProfile.OtherCertificates
            };
            StatusMessage = statusMessage;

            return(Page());
        }