Exemplo n.º 1
0
 public void TearDown()
 {
     _viewModel        = null;
     _workoutGenerator = null;
     _dataService      = null;
     _sessionService   = null;
 }
        public MainPlannerWindowViewModel(MetroWindow w)
        {
            _window = w;

            CapacityViewCommand = new DelegateCommand(() => SetView(_capacityViewModel));
            AboutViewCommand    = new DelegateCommand(() => SetView(_aboutViewModel));
            SettingsViewCommand = new DelegateCommand(() => SetView(_settingsViewModel));
            PlanningViewCommand = new DelegateCommand(() => SetView(_planningViewModel));
            LoginViewCommand    = new DelegateCommand(() => SetView(_loginViewModel));
            LogoutCommand       = new DelegateCommand(LogoutExecute);

            LogoutVisibility = Visibility.Collapsed;

            _planningViewModel              = new PlanningViewModel(w);
            _capacityViewModel              = new CapacityViewModel(w);
            _settingsViewModel              = new SettingsViewModel();
            _loginViewModel                 = new LoginViewModel(w);
            _loginViewModel.LoginSucceeded += LoginSucceededHandler;
            var assembly = Assembly.GetExecutingAssembly();

            _aboutViewModel = new AboutViewModel(w)
            {
                ProductName    = ((AssemblyTitleAttribute)assembly.GetCustomAttribute(typeof(AssemblyTitleAttribute))).Title,
                ProductVersion = assembly.GetName().Version.ToString()
            };
        }
        public async Task <IActionResult> Index()
        {
            var userId = User.FindFirstValue(ClaimTypes.NameIdentifier) ?? throw new ArgumentNullException("User.FindFirstValue(ClaimTypes.NameIdentifier)");

            PlanningViewModel planningViewModel = new PlanningViewModel
            {
                Plans        = await _context.Plans.Where(x => x.UserId == userId).ToListAsync(),
                GoalTypes    = await _context.GoalTypes.ToListAsync(),
                GoalStatuses = await _context.GoalStatuses.ToListAsync(),
            };

            List <int> planIds     = new List <int>();
            List <int> categoryIds = new List <int>();

            foreach (var plan in planningViewModel.Plans)
            {
                planIds.Add(plan.Id);
                categoryIds.Add(plan.EventCategoryId);
            }

            planningViewModel.Goals = await _context.Goals.Where(g => planIds.Contains(g.PlanId)).ToListAsync();

            planningViewModel.EventCategories = await _context.EventCategories.Where(g => categoryIds.Contains(g.Id)).ToListAsync();

            var eventCategories = new SelectList(_context.EventCategories.ToList(), "Id", "CategoryTitle");

            ViewBag.EventCategoryList = eventCategories;

            return(View(planningViewModel));
        }
Exemplo n.º 4
0
 public void Setup()
 {
     _dataService      = new Mock <IDataService>();
     _sessionService   = new Mock <ISessionService>();
     _workoutGenerator = new Mock <IWorkoutGenerator>();
     _viewModel        = new PlanningViewModel(_dataService.Object, _sessionService.Object, _workoutGenerator.Object);
 }
Exemplo n.º 5
0
        public ActionResult Planning()
        {
            var model = new PlanningViewModel();

            model.SelectableCustomers = _customerDynamicsRepository.GetSelectableCustomers();

            var defaultCustomer = new SelectListItem()
            {
                Text  = "--Select Customer--",
                Value = null
            };

            model.SelectableCustomers.Insert(0, defaultCustomer);

            model.SelectableFoundries = _foundryDynamicsRepository.GetSelectableFoundries();

            var defaultFoundry = new SelectListItem()
            {
                Text  = "--Select Foundry--",
                Value = null
            };

            model.SelectableFoundries.Insert(0, defaultFoundry);

            return(View(model));
        }
        public ActionResult ClientPlanning(PlanningViewModel.PlanningListViewModel model)
        {
            if (UserStillLoggedIn() || !(_gebruikerRepository.FindById((int)Session["gebruiker"]) is Client))
            {
                return ReturnToLogin();
            }

            var client = (Client)_gebruikerRepository.FindById((int)Session["gebruiker"]);

            if (ModelState.IsValid)
            {
                client.AddPlanning(model.ClientPlanningViewModel.Datum, model.ClientPlanningViewModel.Activiteit);

                _gebruikerRepository.SaveChanges();
                this.AddNotification("Dit is gepland", NotificationType.SUCCESS);
                return RedirectToAction("ClientPlanning");
            }

            var plvm = new PlanningViewModel.PlanningListViewModel();

            foreach (var i in client.GetPlanning())
            {
                plvm.AddItem(new PlanningViewModel.PlanningItemViewModel(i.Id, i.Actie, i.Datum, i.Verwijderbaar));
            }

            return View(plvm);
        }
        public IActionResult Index()
        {
            PlanningViewModel vm = new PlanningViewModel()
            {
                Kitchen = _db.Kitchens.First(x => x.ID == _userService.User.KitchenID).Name,
                Today   = DateTime.Now.ToShortDateString()
            };

            return(View(vm));
        }
Exemplo n.º 8
0
        async void InitializePage(object obj)
        {
            var param = (PlanningParameter)obj;

            ViewModel = new PlanningViewModel();
            ViewModel.Initialize(param);
            DataContext = ViewModel;

            await ViewModel.PlanAsync(param);

            if (ViewModel.FoundRoutes.Any())
            {
                ResultList.SelectedItem = ViewModel.FoundRoutes.First();
            }
        }
        public async Task <IActionResult> GetPlanning([FromRoute] DateTime date)
        {
            var token = GetToken();

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            if (!TokenService.ValidateToken(token) || !TokenService.VerifDateExpiration(token))
            {
                return(Unauthorized());
            }

            try
            {
                DayOfWeek today = date.DayOfWeek;

                PlanningViewModel planningVM = new PlanningViewModel();

                PlanningService planningService = new PlanningService(_context);

                //Get first and last day of current week
                Tuple <DateTime, DateTime> weeksDay        = GetFirstAndLastDaysOfCurrentWeek(date);
                Tuple <DateTime, DateTime> weeksCurrentDay = GetFirstAndLastDaysOfCurrentWeek(DateTime.Today);

                planningVM.StartWeek = weeksDay.Item1;
                planningVM.EndWeek   = weeksDay.Item2;

                //Get count reservations which end or start in the current week
                planningVM.StartReservationCount = planningService.GetStartReservationCountThisWeek(weeksCurrentDay);
                planningVM.EndReservationCount   = planningService.GetEndReservationCountThisWeek(weeksCurrentDay);

                //Get all vehicle count and used vehicle count for today
                planningVM.TotalVehiclesCount = planningService.GetCountTotalVehicles();
                planningVM.UsedVehiclesCount  = planningService.GetUsedCarToday();

                //Get List of vehicule and with reservations for the calendar, on each line, if there is a reservation, display on tooltip the name of the driver
                planningVM.ListOfReservationsByVehicule = planningService.GetReservationsByVehicule(GetFirstAndLastDaysOfCurrentWeek(date));

                return(Ok(planningVM));
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.Message);
                ModelState.AddModelError("Error", "Erreur durant la récupération du planning.");
                return(BadRequest(ModelState));
            }
        }
Exemplo n.º 10
0
        public async Task <IActionResult> Create(PlanningViewModel newPlanModel)
        {
            if (ModelState.IsValid)
            {
                var userId       = User.FindFirstValue(ClaimTypes.NameIdentifier) ?? throw new ArgumentNullException("User.FindFirstValue(ClaimTypes.NameIdentifier)");
                var goalStatuses = await _context.GoalStatuses.ToListAsync();

                var inProgressGoalStatus = goalStatuses.Find(x => x.Status == "In Progress").Id;

                var planStatuses = await _context.PlanStatuses.ToListAsync();

                var inProgressPlanStatus = planStatuses.Find(x => x.Status == "In Progress").Id;

                var newPlan = new Plan
                {
                    Title           = newPlanModel.Title,
                    EventCategoryId = newPlanModel.EventCategoryId,
                    UserId          = userId
                };
                await _context.AddAsync(newPlan);

                await _context.SaveChangesAsync();

                if (newPlanModel.Goals.Count > 0)
                {
                    foreach (var goal in newPlanModel.Goals)
                    {
                        var newGoal = new Goal
                        {
                            PlanId            = newPlan.Id,
                            GoalTypeId        = goal.GoalTypeId,
                            GoalStatusId      = inProgressGoalStatus,
                            Title             = goal.Title,
                            NumericalTarget   = goal.NumericalTarget,
                            NumericalProgress = goal.NumericalProgress
                        };
                        await _context.AddAsync(newGoal);
                    }
                    newPlan.PlanStatusId = inProgressPlanStatus;
                }

                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(newPlanModel));
        }
 public IHttpActionResult Put([FromBody] PlanningViewModel planningViewModel)
 {
     try
     {
         if (!ModelState.IsValid)
         {
             return(BadRequest(ModelState));
         }
         _planningService.Update(AutoMapperGenerator.Mapper.Map <Planning>(planningViewModel));
         return(Ok());
     }
     catch (Exception exception)
     {
         //ErrorSignal.FromCurrentContext().Raise(exception);
         return(InternalServerError(exception));
     }
 }
Exemplo n.º 12
0
        public ViewResult Save(PlanningViewModel plan)
        {
            //Do some validation here.

            PlanningViewModel planningViewModel = new PlanningViewModel(_context, plan.SelectedPlanDate, plan.SelectedStoreId, plan.SelectedClassId);

            int idx = 0;

            foreach (LogEntries entry in planningViewModel.PlanningModel.NextYear)
            {
                entry.SalesPlan          = plan.PlanningModel.NextYear.ElementAt(idx).SalesPlan;
                entry.StockPlanRatio     = plan.PlanningModel.NextYear.ElementAt(idx).StockPlanRatio;
                entry.StockPlan          = plan.PlanningModel.NextYear.ElementAt(idx).StockPlan;
                entry.MarkdownsPlanRatio = plan.PlanningModel.NextYear.ElementAt(idx).MarkdownsPlanRatio;
                entry.SalesPlan          = plan.PlanningModel.NextYear.ElementAt(idx).SalesPlan;
                entry.RecAtRetailPlan    = plan.PlanningModel.NextYear.ElementAt(idx).RecAtRetailPlan;
                idx++;
            }

            planningViewModel.PlanningModel.Save();


            return(View("Index", planningViewModel));
        }
        public IHttpActionResult Post([FromBody] PlanningViewModel planningViewModel)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

                var startTime = planningViewModel.StartTime;
                planningViewModel.StartTime = new DateTime(startTime.Year, startTime.Month, startTime.Day, 0, 0, 0);

                var endTime = planningViewModel.EndTime;
                planningViewModel.EndTime = new DateTime(endTime.Year, endTime.Month, endTime.Day, 23, 59, 59);

                _planningService.Insert(AutoMapperGenerator.Mapper.Map <Planning>(planningViewModel));
                return(CreatedAtRoute("DefaultApi", new { id = planningViewModel.Id }, planningViewModel));
            }
            catch (Exception exception)
            {
                //ErrorSignal.FromCurrentContext().Raise(exception);
                return(InternalServerError(exception));
            }
        }
Exemplo n.º 14
0
        public ViewResult Populate(DateTime SelectedPlanDate, int SelectedStoreId, int SelectedClassId)
        {
            PlanningViewModel planningViewModel = new PlanningViewModel(_context, SelectedPlanDate, SelectedStoreId, SelectedClassId);

            return(View("Index", planningViewModel));
        }
Exemplo n.º 15
0
        // GET: Planning
        //Parameters: JAGToddlerDatabaseContext{context}
        //Description: Navigates to the Planning view and provides a list of stores to populate dropdown.
        public ViewResult Index()
        {
            PlanningViewModel planningViewModel = new PlanningViewModel(_context);

            return(View(planningViewModel));
        }