private void SeedManagers()
        {
            var managersData = File.ReadAllText("Persistence/Data/Managers.json");
            var managers     = JsonConvert.DeserializeObject <JArray>(managersData);

            var seasonTask = _seasonRepository.SingleOrDefaultAsync(s => s.Name == "2018/2019");

            seasonTask.Wait();
            var season = seasonTask.Result;

            foreach (var managerToken in managers)
            {
                var clubName        = managerToken["clubName"].ToString();
                var birthdateString = managerToken["birthdateString"].ToString();

                var clubsTask = _clubRepository.SingleOrDefaultAsync(c => c.Name == clubName);
                clubsTask.Wait();

                var club = clubsTask.Result;
                if (club == null)
                {
                    continue;
                }

                var manager = JsonConvert.DeserializeObject <Manager>(managerToken.ToString(), _jsonSerializerSettings);
                manager.Birthdate = DateTime.ParseExact(birthdateString, "dd/MM/yyyy", CultureInfo.InvariantCulture);

                _managerRepository.Add(manager);

                var squadTask = _squadRepository
                                .SingleOrDefaultAsync(s => s.SeasonId == season.Id && s.ClubId == club.Id);
                squadTask.Wait();

                var squad = squadTask.Result;
                if (squad == null)
                {
                    continue;
                }

                manager.SquadManagers.Add(new SquadManager
                {
                    Squad     = squad,
                    Manager   = manager,
                    StartDate = DateTime.Now
                });
            }

            _unitOfWork.CompleteAsync().Wait();
        }
Example #2
0
        public async Task <ValidationResult> Handle(CreateManagerCommand message, CancellationToken cancellationToken)
        {
            if (!message.IsValid())
            {
                return(message.ValidationResult);
            }
            var manager = new MyManager(message.Id, message.ManagerId, message.UserId);

            if (await _managerRepository.GetByUserId(manager.UserId) != null)
            {
                AddError("The manager name has already been taken.");
                return(ValidationResult);
            }
            _managerRepository.Add(manager);
            return(await Commit(_managerRepository.UnitOfWork));
        }
Example #3
0
        public ActionResult Assign(ManagerViewModel managerViewModel)
        {
            Manager manager = new Manager();

            manager.Id           = managerViewModel.Id;
            manager.RequsitionId = managerViewModel.RequsitionId;
            manager.EmployeeId   = managerViewModel.EmployeeId;
            manager.VehicleId    = managerViewModel.VehicleId;

            bool isSaved = managerRepository.Add(manager);

            if (isSaved)
            {
                TempData["msg"] = "Requsition Assign Successfully";
                return(RedirectToAction("New"));
            }
            return(View());
        }
        //Saved de veranderingen in de tabel: Applicationuser
        public void Save(Models.Manager manager)
        {
            if (manager == null)
            {
                throw new ArgumentException("user");
            }


            if (manager.ManagerID == 0)
            {
                _repository.Add(manager);
            }
            else
            {
                _repository.Edit(manager);
            }

            _uow.Commit();
        }
Example #5
0
        public void Add(UserModel model)
        {
            long userId;

            switch (model.RoleType)
            {
            case RoleType.Admin:
                userId = _admins.Add(model.Name, model.Authentication.Login, model.Email, TwoLetterISOLanguageName.English);
                break;

            case RoleType.Manager:
                userId = _managers.Add(model.Name, model.Authentication.Login, model.Email, TwoLetterISOLanguageName.English);
                break;

            case RoleType.Broker:
                userId = _brokers.Add(model.Name, model.Authentication.Login, model.Email, TwoLetterISOLanguageName.English);
                break;

            default:
                throw new ArgumentOutOfRangeException("model", @"Unknown role " + model.RoleType);
            }

            _users.SetPassword(userId, model.Authentication.NewPassword);
        }
 public async Task CreateAsync(Manager manager)
 {
     _managerRepository.Add(manager);
     await _unitOfWork.CompleteAsync();
 }
Example #7
0
        private Task <Unit> PersistManager(HireManager command)
        {
            var manager = Mapper.Map <Manager>(command);

            return(_managerRepository.Add(manager));
        }