コード例 #1
0
        public IActionResult Index(int clientId)
        {
            Client client = new Client();

            client = clientRepo.GetClientById(clientId);
            return(View(client));
        }
コード例 #2
0
        public IActionResult Edit(int id)  // The Admin uses this to edit client information
        {
            Client client = new Client();

            client = clientRepo.GetClientById(id);
            return(View(client));
        }
コード例 #3
0
        public ActionResult EditWorkout(WorkoutVM w)
        {
            IWorkoutRepo wrepo = WorkoutRepoFactory.Create();
            IClientRepo  repo  = ClientRepoFactory.Create();
            ITrainerRepo trepo = TrainerRepoFactory.Create();

            if (ModelState.IsValid)
            {
                var workout = new Workout
                {
                    WorkoutID          = w.WorkoutID,
                    WorkoutName        = w.WorkoutName,
                    WorkoutDescription = w.WorkoutDescription,
                };
                foreach (var trainerID in w.SelectedTrainerID)
                {
                    workout.TrainerCreator.Add(trepo.GetTrainerById(trainerID));
                }
                foreach (var clientID in w.SelectedClientID)
                {
                    workout.ClientsOnWorkout.Add(repo.GetClientById(clientID));
                }
                wrepo.EditWorkout(workout);
            }
            return(RedirectToAction("WorkoutList"));
        }
コード例 #4
0
        public ActionResult AddTrainer(TrainerVM t)
        {
            ITrainerRepo trepo = TrainerRepoFactory.Create();
            IClientRepo  repo  = ClientRepoFactory.Create();

            if (ModelState.IsValid)
            {
                var trainer = new Trainer
                {
                    StartDate   = DateTime.Today,
                    TrainerID   = t.TrainerID,
                    TrainerName = t.TrainerName,
                    HourlyRate  = t.HourlyRate
                };
                foreach (var clientID in t.SelectedClientID)
                {
                    trainer.Clientelle.Add(repo.GetClientById(clientID));
                }
                trepo.AddTrainer(trainer);
            }
            else
            {
                return(View(t));
            }
            return(RedirectToAction("Index", "Home"));
        }
コード例 #5
0
        public void GetGetClientById()
        {
            //Arrange
            Client client = new Client();
            int    id     = 2;

            //Act
            client = clientRepo.GetClientById(id);
            //Assert
            Assert.Equal("Henry", client.FirstName);
        }
コード例 #6
0
        public async Task <ActionResult <ClientDisplayDto> > GetClientById(int clientId)
        {
            var clients = await _clientRepo.GetClientById(clientId);

            if (clients == null)
            {
                return(NotFound());
            }
            else
            {
                return(Ok(_mapper.Map <ClientDisplayDto>(clients)));
            }
        }
コード例 #7
0
        public ActionResult EditClient(int id)
        {
            IClientRepo repo   = ClientRepoFactory.Create();
            var         client = repo.GetClientById(id);
            var         model  = new ClientVM
            {
                ClientId       = client.ClientID,
                ClientName     = client.ClientName,
                StartingWeight = client.StartingWeight,
                CurrentWeight  = client.CurrentWeight,
                FitnessGoals   = client.FitnessGoals,
                ClientTrainer  = client.ClientTrainer
            };

            return(View(model));
        }
コード例 #8
0
        public async Task <List <ViewModelOrder> > Get()
        {
            _logger.LogInformation("Get items");
            var orderList = await _orderRepo.GetAllOrders();

            var modelOrders = new List <ViewModelOrder>();

            foreach (var order in orderList)
            {
                var client = await _clientRepo.GetClientById(order.ClientId);

                var kadett = await _kadettRepo.GetKadettById(order.KadettId);

                var modelTickets = new List <ViewModelTicket>();
                var orderTickets = await _ticketOrderRepo.GetTicketOrderByOrderId(order.Id);

                foreach (var orderTicket in orderTickets)
                {
                    var tickets = await _ticketRepo.GetTicketById(orderTicket.TicketId);

                    var vmTicket = new ViewModelTicket()
                    {
                        Type     = tickets.Type,
                        Quantity = orderTicket.Quantity,
                        Day      = orderTicket.Day
                    };
                    modelTickets.Add(vmTicket);
                }

                var vm = new ViewModelOrder
                {
                    Email           = client.Email,
                    Phone           = client.Phone,
                    Bemerkung       = order.Bemerkung,
                    ClientFirstName = client.FirstName,
                    ClientLastName  = client.LastName,
                    Tickets         = modelTickets,
                    KadettFirstName = kadett.FirstName,
                    KadettLastName  = kadett.LastName,
                    KadettInKader   = kadett.KadettInKader
                };
                modelOrders.Add(vm);
            }


            return(modelOrders);
        }
コード例 #9
0
        public ActionResult EditTrainer(TrainerVM t)
        {
            IClientRepo  repo  = ClientRepoFactory.Create();
            ITrainerRepo trepo = TrainerRepoFactory.Create();

            if (ModelState.IsValid)
            {
                var trainer = new Trainer
                {
                    Clientelle  = new List <Client>(),
                    TrainerID   = t.TrainerID,
                    TrainerName = t.TrainerName,
                    HourlyRate  = t.HourlyRate,
                    StartDate   = t.StartDate,
                };
                foreach (var clientID in t.SelectedClientID)
                {
                    trainer.Clientelle.Add(repo.GetClientById(clientID));
                }
                trepo.EditTrainer(trainer);
            }
            return(RedirectToAction("Index", "Home"));
        }
コード例 #10
0
        public IActionResult CreateProject(VMCreateProject projectVM)
        {
            //if model requirements fulfilled
            if (ModelState.IsValid)
            {
                //finds user in Clients based on Email from user
                Client client = clientRepo.GetClientByEmail(projectVM.Email);

                if (clientRepo.ContainsClient(client) == true) //(client != null)
                {
                    //if client is entered and found

                    //searches for open bid for given client
                    Bid bid = bidrepo.GetBidByID(projectVM.BidID);

                    if (bid != null)
                    {
                        //create project
                        Project project = new Project
                        {
                            ProjectID        = projectVM.ProjectID,
                            Client           = clientRepo.GetClientById(projectVM.ClientID),
                            ProjectName      = projectVM.ProjectName,
                            StartDate        = projectVM.StartDate,
                            OriginalEstimate = projectVM.Estimate,
                            Bid           = bidrepo.GetBidByID(projectVM.BidID),
                            ProjectStatus = "Started", StatusDate = DateTime.Today
                        };
                        project.TotalCost = project.OriginalEstimate;

                        //if client and bid are valid
                        if (project.Client != null && project.Bid != null)
                        {
                            //add project to database
                            projectRepo.ProjectUpdate(project);
                        }
                        else
                        {
                            ModelState.AddModelError("Email", "Either the attributed Client or Bid is invalid");
                        }

                        return(RedirectToAction("AdminPage", "Admin"));
                    }
                    else
                    {
                        //if bid not found
                        ModelState.AddModelError("Email", "Could not find open bid for client tied to that email");
                    }
                }
                else
                {
                    //if user not found
                    ModelState.AddModelError("LastName", "There is no client found in the system with that e-mail");
                }
            }
            else
            {
                //if model not valid
                ModelState.AddModelError("Email", "Please make sure all fields are filled");
            }

            return(View(projectVM));
        }