예제 #1
0
        public async Task <IReadOnlyList <ParticipantViewModel> > GetParticipantListAsync()
        {
            var userList = await _userService.GetUserListAsync();

            List <ParticipantViewModel> participants = new List <ParticipantViewModel>();

            foreach (var user in userList)
            {
                ParticipantViewModel participant = new ParticipantViewModel
                {
                    FullName           = user.FirstName + ' ' + user.LastName,
                    Nationality        = user.Nationality,
                    PlaceOfWork        = user.PlaceOfWork,
                    YearsQualified     = user.YearsQualified,
                    YearsInPath        = user.YearsInPath,
                    IsBreastSpecialist = user.IsBreastSpecialist,
                    InControlGroup     = user.InControlGroup,
                    //Code = user.Code,
                    CompleteStudy = user.CompleteStudy
                };

                participants.Add(participant);
            }

            return(participants);
        }
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            Participant _participant = participantService.GetById((int)id);

            if (_participant == null)
            {
                return(HttpNotFound());
            }

            if (!_participant.Team.Coach.Equals(User.Identity.Name))
            {
                return(RedirectToAction("Details", "Teams", new { id = _participant.TeamId }));
            }

            var participantViewModel = new ParticipantViewModel()
            {
                Participant = _participant,
                RankingList = GetRankingList(_participant.Team.Tournament)
            };

            return(View(participantViewModel));
        }
예제 #3
0
        public ActionResult Index(int id, bool official)
        {
            var contest = this.Data.Contests.GetById(id);

            ValidateContest(contest, official);

            var participantFound = this.Data.Participants.Any(id, this.UserProfile.Id, official);

            if (!participantFound)
            {
                if (!contest.ShouldShowRegistrationForm(official))
                {
                    this.Data.Participants.Add(new Participant(id, this.UserProfile.Id, official));
                    this.Data.SaveChanges();
                }
                else
                {
                    // Participant not found, the contest requires password or the contest has questions
                    // to be answered before registration. Redirect to the registration page.
                    // The registration page will take care of all security checks.
                    return(this.RedirectToAction("Register", new { id, official }));
                }
            }

            var participant          = this.Data.Participants.GetWithContest(id, this.UserProfile.Id, official);
            var participantViewModel = new ParticipantViewModel(participant, official);

            this.ViewBag.CompeteType = official ? CompeteUrl : PracticeUrl;

            return(this.View(participantViewModel));
        }
        public ActionResult Create(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            Team team = teamService.GetById((int)id);

            if (team == null)
            {
                return(HttpNotFound());
            }

            if ((User.Identity.Name.Equals(team.Coach) && team.Tournament.Status == TournamentStatus.OpenedForRegistration) ||
                (User.Identity.Name.Equals(team.Tournament.Organizer) && team.Tournament.Status == TournamentStatus.CheckingData))
            {
                var participantViewModel = new ParticipantViewModel()
                {
                    Participant = new Participant()
                    {
                        TeamId = (int)id
                    },
                    RankingList = GetRankingList(team.Tournament)
                };
                return(View(participantViewModel));
            }
            else
            {
                return(RedirectToAction("Details", "Teams", new { id = team.TournamentId }));
            }
        }
        public ActionResult ParticipantDetails(int id)
        {
            var participant = _unitOfWork.Participants.GetParticipantById(id);
            var vm          = new ParticipantViewModel(participant.FirstName, participant.LastName, participant.Id, participant.HairColor, participant.Hobbies, participant.EyeColor, participant.FavoriteFood, participant.FavoriteColor, participant.Sponsor);

            return(View(vm));
        }
예제 #6
0
        public ActionResult Save(ParticipantViewModel participantViewModel, IFormFile file)
        {
            if (ModelState.IsValid)
            {
                Participant participant = _mapper.Map <Participant>(participantViewModel);

                if (_partyService.ParticipantBelongUser(participant))
                {
                    if (file != null && file.Length > 0)
                    {
                        string _path = Path.Combine(_env.WebRootPath, "ParticipansPhoto", String.Concat(participant.Name, new FileInfo(file.FileName).Extension));
                        using (var stream = new FileStream(_path, FileMode.Create))
                        {
                            file.CopyTo(stream);
                        }
                    }

                    _partyService.Vote(participant);
                    return(RedirectToAction("Index", new { id = participantViewModel.PartyId }));
                }
                else
                {
                    ModelState.AddModelError(string.Empty, _localizer["NameIsRegistered"]);
                }
            }

            return(View("Vote", participantViewModel));
        }
예제 #7
0
        public ActionResult Index(int id, bool official, bool?hasConfirmed)
        {
            var contest = this.contestsData.GetById(id);

            try
            {
                this.ValidateContest(contest, official);

                var participantFound = this.Data.Participants.Any(id, this.UserProfile.Id, official);

                if (!participantFound)
                {
                    var shouldShowConfirmation = official &&
                                                 contest.IsOnline &&
                                                 (!hasConfirmed.HasValue ||
                                                  hasConfirmed.Value == false) &&
                                                 contest.Duration.HasValue &&
                                                 !this.IsUserAdminOrLecturerInContest(contest);

                    if (shouldShowConfirmation)
                    {
                        return(this.View("ConfirmCompete", new OnlineContestConfirmViewModel
                        {
                            ContesId = contest.Id,
                            ContestName = contest.Name,
                            ContestDuration = contest.Duration.Value,
                            ProblemGroupsCount = contest.NumberOfProblemGroups
                        }));
                    }
                }

                if (official &&
                    !this.contestsBusiness.IsContestIpValidByContestAndIp(id, this.Request.UserHostAddress))
                {
                    return(this.RedirectToAction(c => c.NewContestIp(id)));
                }

                if (!participantFound)
                {
                    return(this.RedirectToAction(c => c.Register(id, official)));
                }
            }
            catch (HttpException httpEx)
            {
                this.TempData.AddDangerMessage(httpEx.Message);
                return(this.RedirectToAction <HomeController>(c => c.Index(), new { area = string.Empty }));
            }

            var participant = this.participantsData
                              .GetWithContestByContestByUserAndIsOfficial(id, this.UserProfile.Id, official);
            var participantViewModel = new ParticipantViewModel(
                participant,
                official,
                this.IsUserAdminOrLecturerInContest(contest));

            this.ViewBag.CompeteType           = official ? CompeteActionName : PracticeActionName;
            this.ViewBag.IsUserAdminOrLecturer = this.IsUserAdminOrLecturerInContest(contest);

            return(this.View(participantViewModel));
        }
        public void ShowWindow(BaseViewModel viewModel, bool showAsDialog = false)
        {
            Window window = viewModel switch
            {
                // Wenn viewModel null ist -> ArgumentNullException
                null => throw new ArgumentNullException(nameof(viewModel)),

                      MainViewModel _ => new MainWindow(),
                      ParticipantViewModel _ => new ParticipantWindow(),

                      // default -> InvalidOperationException
                      _ => throw new InvalidOperationException($"Unbekanntes ViewModel '{viewModel}'"),
            };

            _windows[viewModel] = window;

            window.DataContext = viewModel;

            if (showAsDialog)
            {
                window.ShowDialog();
            }
            else
            {
                window.Show();
            }
        }
예제 #9
0
        public async Task <IActionResult> Delete(int id)
        {
            Participant participant = await context.Participants.FindAsync(id);

            ParticipantViewModel model = ViewModelFactory.Delete(participant);

            return(View("ParticipantEditor", model));
        }
        // POST: api/Participant
        public IHttpActionResult PostPerson(ParticipantViewModel participant)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            //Add HouseholdId
            if (participant.HouseholdId == null)
            {
                var household = new Household();
                household.AddressStreet     = participant.Street;
                household.AddressSuburb     = participant.Suburb;
                household.AddressPostcode   = participant.Postcode;
                household.AddressState      = participant.State;
                household.PhoneHome         = participant.PhoneHome;
                household.LastConfirmedBy   = participant.LastConfirmedBy;
                household.LastConfirmedWhen = participant.LastConfirmedWhen;
                household.AddresseeId       = participant.HouseholdAddressee;
                household.ActiveAddress     = household.ActiveAddress;
                db.Households.Add(household);
                db.SaveChanges();

                participant.HouseholdId = db.Households.Max(x => x.HouseholdId);
            }

            //Add Participant
            var mapper = new ParticipantMapper();
            var person = mapper.GetParticipantModel(participant);

            db.People.Add(person);
            db.SaveChanges();

            if (participant.StudyId != 0)
            {
                //Add in Linked Stuby Table
                var linkedStudy = new LinkSubjectsStudy();
                linkedStudy.PersonId = db.People.Max(x => x.PersonId);
                linkedStudy.StudyId  = participant.StudyId;
                db.LinkSubjectsStudies.Add(linkedStudy);
                db.SaveChanges();
            }

            //Add household members
            foreach (var member in participant.HouseholdMembers)
            {
                member.HouseholdId = participant.HouseholdId;
                member.Gender      = member.Gender == "M" ? "Male" : (member.Gender == "F" ? "Female" : "");
                var familyMember = mapper.GetParticipantModel(member);
                db.People.Add(familyMember);
                db.SaveChanges();
            }



            return(Ok(participant));
        }
 public void ClearChatMessages(ParticipantViewModel participantViewModel)
 {
     Application.Current.Dispatcher?.BeginInvoke(
         System.Windows.Threading.DispatcherPriority.Background, new Action(() =>
     {
         participantViewModel.Messages.Clear();
     }
                                                                            ));
 }
 public void RemoveParticipantFromParticipants(ParticipantViewModel removeParticipantViewModel)
 {
     Application.Current.Dispatcher?.BeginInvoke(
         System.Windows.Threading.DispatcherPriority.Background, new Action(() =>
     {
         Participants.Remove(Participants.Single(x => x.ConnectionId == removeParticipantViewModel.ConnectionId));
     }
                                                                            ));
 }
예제 #13
0
        public async Task <IActionResult> Details(int id)
        {
            Participant participant = await context.Participants
                                      .FirstOrDefaultAsync(p => p.Id == id);

            ParticipantViewModel model = ViewModelFactory.Details(participant);

            return(View("ParticipantEditor", model));
        }
예제 #14
0
 public IActionResult AddParticipantInCase(ParticipantViewModel model)
 {
     if (ModelState.IsValid)
     {
         CaseUserDTO _newCaseUser = CreateCaseUser(model);
         _caseService.AddParticipant(model.CaseId, _newCaseUser);
         return(RedirectToAction("AboutCase", "Case", new { id = model.CaseId }));
     }
     return(PartialView(model));
 }
        public static Participant ReturnParticipant(ParticipantViewModel model, Participant participant)
        {
            participant.BirthDate    = model.BirthDate;
            participant.Cpf          = model.Cpf;
            participant.DateModified = DateTime.UtcNow.ToBrazillianDate();
            participant.Gender       = model.Gender;
            participant.Name         = model.Name;

            return(participant);
        }
        public ActionResult Create(ParticipantViewModel _participantViewModel)
        {
            if (ModelState.IsValid)
            {
                participantService.Create(_participantViewModel.Participant);
                return(RedirectToAction("Details", "Teams", new { id = _participantViewModel.Participant.TeamId }));
            }
            Team team = teamService.GetById(_participantViewModel.Participant.TeamId);

            _participantViewModel.RankingList = GetRankingList(team.Tournament);
            return(View(_participantViewModel));
        }
        public ActionResult Index(ParticipantViewModel participant = null)
        {
            var Participants = _unitOfWork.Participants.GetParticipants(User.Identity.GetUserId());
            var vm           = _unitOfWork.Participants.GenreateParticipantIndexViewModel(Participants);

            vm.AddParticipant = participant;



            vm.EventNames = _unitOfWork.Events.EventNames();
            return(View(vm));
        }
예제 #18
0
        private bool Update(string key, ParticipantViewModel model)
        {
            var data = Find(model.Id);

            if (data != null)
            {
                data.Score            = model.Score;
                data.TimeSpent        = model.TimeSpent;
                data.LastModifiedDate = DateTime.Now;
                return(true);
            }
            return(false);
        }
예제 #19
0
        public static ParticipantDBViewModel storingtoDB(ParticipantViewModel Participantvalues, ScoreModel score, GeoLocProps geo, UserAgent.UserAgent useragent, MapPoint mapCords)
        {
            ParticipantDBViewModel dbModel = new ParticipantDBViewModel();

            dbModel.Age                    = Participantvalues.Age;
            dbModel.AgeValid               = score.AgeValid;
            dbModel.City                   = Participantvalues.City;
            dbModel.CityValid              = score.CityValid;
            dbModel.Date_of_Birth          = DateTime.Parse(Participantvalues.MonthofBirth + "/" + Participantvalues.YearofBirth);
            dbModel.EmailAddress           = Participantvalues.EmailAddress;
            dbModel.FirstName              = Participantvalues.FirstName;
            dbModel.FirstName_Match        = score.FirstName_Match;
            dbModel.LastName               = Participantvalues.LastName;
            dbModel.LastName_Match         = score.LastName_Match;
            dbModel.cords_IpAddrMatch      = score.Coordinates_Match;
            dbModel.OtherGenderType        = Participantvalues.othergender;
            dbModel.GenderIdentity         = Participantvalues.GenderIdentity;
            dbModel.OtherSexualOrientation = Participantvalues.otherSex;
            dbModel.OtherRace              = Participantvalues.OtherRace;
            dbModel.Password               = "";
            dbModel.Hispanic               = Participantvalues.Hispanic;
            dbModel.PhoneNumber            = Participantvalues.PhoneNumber;
            dbModel.Race                   = Participantvalues.Race;
            dbModel.SexualOrientation      = Participantvalues.SexualOrientation;
            dbModel.State                  = Participantvalues.State;
            dbModel.StateValid             = score.StateValid;
            dbModel.Verified               = score.Verified;
            dbModel.Zip                    = Participantvalues.Zip;
            dbModel.geo_IP                 = geo.IP;
            dbModel.geo_City               = geo.City;
            dbModel.geo_CountryName        = geo.CountryName;
            dbModel.geo_RegionName         = geo.RegionName;
            dbModel.geo_ZipCode            = geo.ZipCode;
            dbModel.geo_lattude            = geo.Latitude;
            dbModel.geo_longitude          = geo.Longitude;
            dbModel.OS      = useragent.OS.Name.ToString();
            dbModel.Browser = useragent.Browser.Name.ToString();

            dbModel.AddrLatitude  = mapCords.Latitude;
            dbModel.AddrLongitude = mapCords.Longitude;
            dbModel.latlangMatch  = mapCords.MatchCords;

            dbModel.FinalScaoreVal = score.FinalScaoreVal;
            dbModel.TwoFactorScore = score.TwoFactorScore;
            dbModel.SocialScore    = score.SocialScore;
            dbModel.AgeScore       = score.AgeScore;
            dbModel.AddressScore   = score.AddressScore;
            dbModel.RegisterDate   = DateTime.Now.ToString("U");
            return(dbModel);
        }
예제 #20
0
        public Participant Insert(ParticipantViewModel model)
        {
            Participant newParticipant = new Participant()
            {
                Name  = model.Name,
                Email = model.Email,

                Delete           = false,
                CreateDate       = DateTime.Now,
                LastModifiedDate = DateTime.Now,
            };

            base.Insert(newParticipant);
            return(newParticipant);
        }
        public ActionResult EditParticipant(ParticipantViewModel vm, string id)
        {
            var Id          = Convert.ToInt32(id);
            var participant = _unitOfWork.Participants.GetParticipantById(Id);

            participant.Update(vm.EyeColor, vm.FavoriteColor, vm.FavoriteFood, vm.HairColor, vm.Hobbies, vm.Sponsor);
            if (User.Identity.GetUserId() == participant.UserId || User.IsInRole("Admin"))
            {
                _unitOfWork.Complete();
                return(RedirectToAction("ParticipantDetails", new { id = Id }));
            }


            return(View("Index"));
        }
예제 #22
0
        // GET: Participant/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Participant participant = db.Participants.Find(id);

            if (participant == null)
            {
                return(HttpNotFound());
            }
            var participantViewModel = new ParticipantViewModel(participant);

            return(View(participantViewModel));
        }
예제 #23
0
        public ActionResult Modify(ParticipantViewModel _model, string save, string delete)
        {
            var tmpProduct = participantList.Find(x => x.Id == _model.Id);

            if (save != null)
            {
                tmpProduct.Name     = _model.Name;
                tmpProduct.Birthday = _model.Birthday;
                tmpProduct.Team     = _model.Team;
            }
            else if (delete != null)
            {
                participantList.Remove(tmpProduct);
            }
            return(RedirectToAction("Index"));
        }
예제 #24
0
        public ActionResult AddNewParticipant(ParticipantViewModel model)
        {
            Response response = new Response();

            if (ModelState.IsValid)
            {
                try
                {
                    if (model.participantId == 0)
                    {
                        var NewParticipant = new Participants
                        {
                            ParticipantName = model.ParticipantName,
                        };

                        _context.Participants.Add(NewParticipant);
                        _context.SaveChanges();

                        response.Success = true;
                        response.Message = "Saved Successfully";
                    }
                }
                catch (Exception e)
                {
                    response.Success  = false;
                    response.Message += "Error => " + e.Message;
                    return(Json(response));
                }
            }
            else
            {
                foreach (var modelStateKey in ViewData.ModelState.Keys)
                {
                    var modelStateVal = ViewData.ModelState[modelStateKey];
                    foreach (var error in modelStateVal.Errors)
                    {
                        var key          = modelStateKey;
                        var errorMessage = error.ErrorMessage;
                        response.Message += key + " => " + error.ErrorMessage + "\n";
                    }
                }

                return(Json(response));
            }
            return(Json(response));
        }
예제 #25
0
        public IList <ParticipantViewModel> GetBoardParticipant(int id, int count = 5000)
        {
            List <ParticipantViewModel> list = new List <ParticipantViewModel>();

            var board = _repos.DiscussionBoards
                        .GetWith(id,
                                 "Unit",
                                 "Unit.Lecturer",
                                 "Unit.Lecturer.Profile",
                                 "Unit.UnitStudents",
                                 "Unit.UnitStudents.Student",
                                 "Unit.UnitStudents.Student.Profile");

            if (board == null)
            {
                return(list);
            }
            else
            {
                if (board.Unit.Lecturer != null)
                {
                    var lec = new ParticipantViewModel(AccountType.Lecturer)
                    {
                        AccountId = board.Unit.Lecturer.Id,
                        Names     = board.Unit.Lecturer.Profile.FullNames,
                        Photo     = board.Unit.Lecturer.Profile.PhotoUrl
                    };

                    list.Add(lec);
                }

                var others = board.Unit
                             .UnitStudents
                             .Select(x => new ParticipantViewModel(AccountType.Student)
                {
                    AccountId = x.StudentId,
                    Names     = x.Student.Profile.FullNames,
                    Photo     = x.Student.Profile.PhotoUrl
                }).ToList();

                list.AddRange(others);
            }

            return(list.Take(count).ToList());
        }
        public IHttpActionResult GetParticipant(int id)
        {
            Participant participant = db.Participants.Find(id);

            if (participant == null)
            {
                return(NotFound());
            }
            ParticipantViewModel participantViewModel = new ParticipantViewModel
            {
                @event   = Url.Link("getEvent", new { id = participant.EventId }),
                children = Url.Link("getChildren", new { id = participant.ChildrenId }),
                Lane     = participant.Lane,
                Time     = participant.Time
            };

            return(Ok(participantViewModel));
        }
        public async Task <IActionResult> Put(string key, ParticipantViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            try
            {
                var participant = await _participantService.UpdateAsync(key, model);

                _unitOfWorkAsync.Commit();
                return(Ok(model));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public async Task <IActionResult> Post(ParticipantViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            try
            {
                var participant = await _participantService.InsertAsync(model);

                _unitOfWorkAsync.Commit();
                return(Created("Created new participant", participant));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #29
0
 private CaseUserDTO CreateCaseUser(ParticipantViewModel model)
 {
     {
         return(new CaseUserDTO
         {
             Name = model.Name,
             Surname = model.Surname,
             Patronymic = model.Patronymic,
             DateOfBirth = model.DateOfBirth,
             Address = model.Address,
             Phone = model.Phone,
             HomePhone = model.HomePhone,
             Email = model.Email,
             CaseId = model.CaseId,
             RoleInTheCaseId = model.RoleId
         });
     }
 }
        //
        // GET: /Participants/
        public ActionResult Index(int page = 1)
        {
            var pageSize  = 2;
            var viewModel = new ParticipantViewModel
            {
                Participants = _repository.Query.OrderBy(p => p.Id).Skip((page - 1) * pageSize).Take(pageSize).ToList(),
                Pagination   = new PaginationViewModel
                {
                    CurrentPage  = page,
                    ItemsPerPage = pageSize,
                    TotalCount   = _repository.Query.Count(),
                    Controller   = RouteData.Values["Controller"] as string,
                    Action       = RouteData.Values["Action"] as string
                }
            };

            return(View(viewModel));
        }