예제 #1
0
        public async Task <IActionResult> UniqueYearPlan(YearPlanViewModel model)
        {
            // Get list of user's yearplans
            var userYearPlans = await _yearPlanRepository.GetByUser(LoggedUser);

            var list = userYearPlans.ToList();

            foreach (var item in list)
            {
                if (item.StartYear == model.StartYear)
                {
                    // If user have yearplan with startYear passed by user error
                    return(Json($"Posiadasz już plan na ten rok"));
                }
            }
            return(Json(true));
        }
예제 #2
0
        public async Task <IActionResult> Create(YearPlanViewModel model, Guid yearPlanImportId)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }
            var yearPlan = new YearPlan()
            {
                StartYear = model.StartYear,
                EndYear   = model.StartYear + 1,
                User      = LoggedUser,
            };

            var yearPlanImport = await _yearPlanRepository.GetByIdToImport(yearPlanImportId);

            if (yearPlanImport != null)
            {
                yearPlan.GetDataToImport(yearPlanImport);
            }
            await _yearPlanRepository.Add(yearPlan);

            TempData["message"] = "Utworzono nowy plan: " + yearPlan.GetYearPlanName;
            return(RedirectToAction("Create"));
        }
예제 #3
0
        public IEnumerable <YearPlanItemViewModel> GetAllDepartmentsYearPlan(YearPlanViewModel model)
        {
            IEnumerable <YearPlanItemViewModel> result = yearlyPlanService.GetYearPlanDepartments(model.JobId, model.Year);

            return(result);
        }