コード例 #1
0
        public ActionResult AddPara(ParaViewModel model)
        {
            try
            {
                if (model.FormOfStudyId == 0 && model.SpezialnostId == 0)
                {

                    Raspisanie paraForGroups = _adminScheduleService.AddPara(model);

                    Spezialnost_SpezialnostMeta spezialnostSpezialnostMeta = paraForGroups.SpezialRazdeliDisziplini.Spezialnost_SpezialnostMeta;
                    string spezialnost1 = spezialnostSpezialnostMeta.Spezialnost.Spezialnost1;

                    return Json(new { message = "Пара добавлена успешно", type = "success", spez = spezialnost1, year = spezialnostSpezialnostMeta.GodPostup, potokId = paraForGroups.Pot, date = paraForGroups.Data.ToShortDateString() });
                }
                else
                {

                    Raspisanie paraForPrepod = _adminScheduleService.AddParaForPrepod(model);

                    int prepodId = paraForPrepod.Prepod_PrepodiCafedri.Prepod_PrepodMeta.UserId;

                    return Json(new { message = "Пара добавлена успешно", type = "success", prepodId, date = paraForPrepod.Data.ToShortDateString() });
                }

            }
            catch (Exception ex)
            {
                return Json(new { message = "Произошла ошибка при добавлении: " + ex.Message, type = "error" });
            }
        }
コード例 #2
0
        public Raspisanie AddParaForPrepod(ParaViewModel model)
        {
            Spezialnost_SpezialnostMeta spezialnostSpezialnostMeta =
                _dataProvider.SpezialnostMeta.FirstOrDefault(
                    x => x.IdSpez == model.SpezialnostId && x.GodPostup == model.Year);

            SpezialRazdeliDisziplini spezialRazdeliDisziplini = _dataProvider.SpezialRazdeliDisziplini.FirstOrDefault(
               x => x.IdDisciplini == model.DisciplineId && x.IdSpezMeta == spezialnostSpezialnostMeta.Id);

            DateTime dateOfPara = DateTime.Parse(model.DateOfPara);

            Prepod_PrepodMeta prepodPrepodMeta = _dataProvider.PrepodMetadata.FirstOrDefault(x => x.UserId == model.PrepodId);
            Prepod_PrepodiCafedri prepodPrepodiCafedri = _dataProvider.PrepodiCafedri.FirstOrDefault(x => x.IdSotr == prepodPrepodMeta.Id);

            Raspisanie raspisanie = new Raspisanie()
            {
                Data = dateOfPara,
                IdUchPlanaDisciplini = spezialRazdeliDisziplini.IdUpPlanDisciplini,
                IdVidaRaboti = model.TypeOfParaId,
                IdVremyaZanyatia = model.TimeOfParaId,
                Pot = model.ПотокИд,//для преподов на русском
                IdSpiskaGrupp = model.GroupId != 0 ? model.GroupId : (int?)null,
                NomerPodGrupp = model.SubgroupId != 0 ? model.SubgroupId : (int?)null,
                IdPrepodaCafedri = prepodPrepodiCafedri.Id,
                NomerZanyatiaVSemestre = 0,
                Auditoriya = model.Auditory,
                TipNagruzki = 80
            };

            bool isParaExist = CheckForParaIdentity(raspisanie);
            bool isPrepodHasNakladki = PrivateCheckForNakladkiForPrepod(raspisanie);
            bool isGroupHasNakladki = PrivateCheckForNakladkiForGroup(raspisanie);

            if (!isParaExist && !isPrepodHasNakladki && !isGroupHasNakladki)
            {
                _dataProvider.Raspisanie.Add(raspisanie);
                _dataProvider.Save();
            }
            else
            {
                throw new ArgumentException("У преподавателя накладки, измените время/дату пары");
            }

            return raspisanie;
        }
コード例 #3
0
        public Raspisanie AddPara(ParaViewModel model)
        {
            SpezialRazdeliDisziplini spezialRazdeliDisziplini = _dataProvider.SpezialRazdeliDisziplini.FirstOrDefault(
                x => x.IdDisciplini == model.DisciplineId && x.IdSpezMeta == model.IdSpezMeta);

            DateTime dateOfPara = DateTime.Parse(model.DateOfPara);

            Raspisanie raspisanie = new Raspisanie()
            {
                Data = dateOfPara,
                IdUchPlanaDisciplini = spezialRazdeliDisziplini.IdUpPlanDisciplini,
                IdVidaRaboti = model.TypeOfParaId,
                IdVremyaZanyatia = model.TimeOfParaId,
                Pot = model.PotokId,
                IdSpiskaGrupp = model.GroupId != 0 ? model.GroupId : (int?)null,
                NomerPodGrupp = model.SubgroupId != 0 ? model.SubgroupId : (int?)null,
                IdPrepodaCafedri = model.PrepodiDisziplineId,
                NomerZanyatiaVSemestre = 0,
                Auditoriya = model.Auditory,
                TipNagruzki = 80
            };

            bool isParaExist = CheckForParaIdentity(raspisanie);
            bool isGroupHasNakladki = PrivateCheckForNakladkiForGroup(raspisanie);
            bool isPrepodHasNakladki = PrivateCheckForNakladkiForPrepod(raspisanie);

            if (!isParaExist && !isGroupHasNakladki && !isPrepodHasNakladki)
            {
                _dataProvider.Raspisanie.Add(raspisanie);
                _dataProvider.Save();
            }
            else
            {
                if (model.GroupId != 0)
                {
                    throw new ArgumentException("У группы накладки, измените время/или дату пары");
                }
                else
                {
                    throw new ArgumentException("У потока накладки, измените время/дату пары");
                }
            }

            return raspisanie;
        }
コード例 #4
0
        public ActionResult Save(ParaViewModel model)
        {
            //TODO: тестирование соединения с БД Белодеда
            string connStringOleDb = ConfigurationManager.AppSettings["OleDbConnString"];
            List<string> dataFromT0005ВремяЗанятия = _syncronizationService.GetDataFrom_t0005_ВремяЗанятия(@connStringOleDb);

            return View();
        }
コード例 #5
0
        /// <summary>
        /// Редактирование пары
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult Edit(int id)
        {
            Raspisanie raspisanie = _adminScheduleService.GetRaspisanie(id);

            //TODO: дописать модель для редактирования
            ParaViewModel paraViewModel = new ParaViewModel()
            {
                Id = raspisanie.Id,
                DateOfPara = raspisanie.Data.ToShortDateString(),
                Auditory = raspisanie.Auditoriya,
                DisciplineId = raspisanie.SpezialRazdeliDisziplini.IdDisciplini,
                TimeOfParaId = raspisanie.IdVremyaZanyatia,

            };

            ViewBag.Id = raspisanie.Id;

            ViewBag.Auditoria = raspisanie.Auditoriya;
            ViewBag.DataZaniat = raspisanie.Data.ToShortDateString();

            ViewBag.VremiaZaniatia = _adminScheduleService.GetVremiaZaniatiu().Select(x => new SelectListItem()
            {
                Selected = raspisanie.IdVremyaZanyatia == x.Key,
                Text = x.Value,
                Value = x.Key.ToString()
            });

            ViewBag.DiszipliniFromSpezialRazdeliDisziplini =
                  _adminScheduleService.GetDiszipliniFromSpezialRazdeliDisziplini(id);

            ViewBag.Prepods = _adminScheduleService.GetAllPrepods().Select(x => new SelectListItem()
             {
                 Selected = raspisanie.Prepod_PrepodiCafedri.Id == x.Key,
                 Text = x.Value,
                 Value = x.Key.ToString()
             });

            ViewBag.Spezialnosti = _scheduleService.GetSpezialnostiForConfiguration().Select(x => new SelectListItem()
            {
                Selected = raspisanie.SpezialRazdeliDisziplini.Spezialnost_SpezialnostMeta.IdSpez == x.Key,
                Text = x.Value,
                Value = x.Key.ToString()
            });

            ViewBag.FormsOfStudy = _scheduleService.GetFormOfStudyForConfiguration(
                raspisanie.SpezialRazdeliDisziplini.Spezialnost_SpezialnostMeta.IdSpez).Select(x => new SelectListItem()
                {
                    Selected = raspisanie.SpezialRazdeliDisziplini.Spezialnost_SpezialnostMeta.IdFrmObuch == x.Key,
                    Text = x.Value,
                    Value = x.Key.ToString()
                });

            ViewBag.GodiPostuplenia = _adminScheduleService.GetGodPostuplinia(
                 raspisanie.SpezialRazdeliDisziplini.Spezialnost_SpezialnostMeta.IdSpez).Select(x => new SelectListItem()
                 {
                     Selected =
                         raspisanie.SpezialRazdeliDisziplini.Spezialnost_SpezialnostMeta.GodPostup ==
                         Int32.Parse(x.Value),
                     Text = x.Text,
                     Value = x.Value
                 });

            ViewBag.Potoki = _adminScheduleService.GetPotoki(raspisanie.SpezialRazdeliDisziplini.Spezialnost_SpezialnostMeta.IdSpez,
                 raspisanie.SpezialRazdeliDisziplini.Spezialnost_SpezialnostMeta.GodPostup)
                 .Select(x => new SelectListItem()
                 {
                     Selected = raspisanie.Pot == x.Key,
                     Text = x.Value,
                     Value = x.Key.ToString()
                 });

            ViewBag.TypesOfZaniatia
                  = _adminScheduleService.GetTypesOfPara().Select(x => new SelectListItem()
              {
                  Selected = raspisanie.IdVidaRaboti == x.Key,
                  Text = x.Value,
                  Value = x.Key.ToString()
              });

            if (raspisanie.IdSpiskaGrupp != null)
            {
                ViewBag.Groups = _adminScheduleService.GetGroups(raspisanie.SpezialRazdeliDisziplini.IdSpezMeta)
              .Select(x => new SelectListItem()
              {
                  Selected = raspisanie.IdSpiskaGrupp == x.Key,
                  Text = x.Value,
                  Value = x.Key.ToString()
              });

                ViewBag.SubGroups = _adminScheduleService.GetSubGroups(raspisanie.SpezialRazdeliDisziplini.IdSpezMeta)
                    .Select(x => new SelectListItem()
                    {
                        Selected = raspisanie.NomerPodGrupp == x.Key,
                        Text = x.Value,
                        Value = x.Key.ToString()
                    });

            }

            return View("Edit", paraViewModel);
        }