コード例 #1
0
        public IActionResult offer(int id = 0)
        {
            ViewBag.ID = id;

            EditOffersVM vm = _userManagementHelper.prepOffer();

            vm.OfferId     = id;
            vm.Offer       = _db.Offer.Where(a => a.OfferId == id).Include(x => x.University).ThenInclude(c => c.Country).FirstOrDefault();
            vm.Nominations = _db.Nomination.Where(a => a.OfferId == id).Include(b => b.Applicant).ThenInclude(c => c.ApplicationUser).ToList();

            return(View(vm));
        }
コード例 #2
0
        public IActionResult offer(EditOffersVM vm)
        {
            Offer current = _db.Offer.Where(a => a.OfferId == vm.Offer.OfferId).Include(x => x.University).ThenInclude(c => c.Country).FirstOrDefault();

            if (current == null)
            {
                Offer novi = new Offer();
                novi.Semester = vm.Offer.Semester;
                novi.Cycles   = "";
                if (vm.Offer.LCycles != null)
                {
                    for (int i = 0; i < vm.Offer.LCycles.Count(); i++)
                    {
                        if (i == vm.Offer.LCycles.Count() - 1)
                        {
                            novi.Cycles += vm.Offer.LCycles[i];
                        }
                        else
                        {
                            novi.Cycles += vm.Offer.LCycles[i] + ", ";
                        }
                    }
                }
                novi.Programmes = "";
                if (vm.Offer.LProgrammes != null)
                {
                    for (int i = 0; i < vm.Offer.LProgrammes.Count(); i++)
                    {
                        if (i == vm.Offer.LProgrammes.Count() - 1)
                        {
                            novi.Programmes += vm.Offer.LProgrammes[i];
                        }
                        else
                        {
                            novi.Programmes += vm.Offer.LProgrammes[i] + ", ";
                        }
                    }
                }
                novi.Start        = vm.Offer.Start.Date;
                novi.End          = vm.Offer.End.Date;
                novi.Info         = vm.Offer.Info;
                novi.UniversityId = vm.Offer.UniversityId;
                _db.Offer.Add(novi);
                _db.SaveChanges();
            }
            else
            {
                current.Semester = vm.Offer.Semester;
                if (vm.Offer.LCycles != null)
                {
                    current.Cycles = "";
                    for (int i = 0; i < vm.Offer.LCycles.Count(); i++)
                    {
                        if (i == vm.Offer.LCycles.Count() - 1)
                        {
                            current.Cycles += vm.Offer.LCycles[i];
                        }
                        else
                        {
                            current.Cycles += vm.Offer.LCycles[i] + ", ";
                        }
                    }
                }
                if (vm.Offer.LProgrammes != null)
                {
                    current.Programmes = "";
                    for (int i = 0; i < vm.Offer.LProgrammes.Count(); i++)
                    {
                        if (i == vm.Offer.LProgrammes.Count() - 1)
                        {
                            current.Programmes += vm.Offer.LProgrammes[i];
                        }
                        else
                        {
                            current.Programmes += vm.Offer.LProgrammes[i] + ", ";
                        }
                    }
                }
                //current.Start = vm.Offer.Start.Date;
                //current.End = vm.Offer.End.Date;
                current.Info         = vm.Offer.Info;
                current.UniversityId = vm.Offer.UniversityId;
                _db.SaveChanges();
            }
            return(RedirectToAction("index", "offers", new { area = "admin" }));
        }
コード例 #3
0
        public EditOffersVM prepOffer()
        {
            EditOffersVM model = new EditOffersVM();

            model.Universities = _db.University.Include(a => a.Country).Where(b => b.UniversityId != 2).Select(x => new SelectListItem()
            {
                Value = x.UniversityId.ToString(),
                Text  = x.Name
            }).OrderBy(a => a.Value).ToList();

            model.Universities.Insert(0, new SelectListItem {
                Value = "", Text = ""
            });

            model.Semesters = new List <SelectListItem>();

            model.Semesters.Add(new SelectListItem()
            {
                Value = "",
                Text  = ""
            });

            model.Semesters.Add(new SelectListItem()
            {
                Value = "Erasmus+, summer",
                Text  = "Erasmus+, summer"
            });

            model.Semesters.Add(new SelectListItem()
            {
                Value = "Erasmus+, winter",
                Text  = "Erasmus+, winter"
            });

            model.Semesters.Add(new SelectListItem()
            {
                Value = "other",
                Text  = "other"
            });

            model.Programmes = new List <SelectListItem>();

            model.Programmes.Add(new SelectListItem()
            {
                Value = "other",
                Text  = "other"
            });

            model.Programmes.Add(new SelectListItem()
            {
                Value = "mechanic engineering",
                Text  = "mechanics engineering"
            });

            model.Programmes.Add(new SelectListItem()
            {
                Value = "civil engineering",
                Text  = "civil engineering"
            });

            model.Programmes.Add(new SelectListItem()
            {
                Value = "IT",
                Text  = "IT"
            });

            model.Programmes.Add(new SelectListItem()
            {
                Value = "business administration",
                Text  = "business administration"
            });

            model.Programmes.Add(new SelectListItem()
            {
                Value = "available in info link",
                Text  = "available in info link"
            });

            model.Cycles = new List <SelectListItem>();

            model.Cycles.Add(new SelectListItem()
            {
                Value = "bachelor",
                Text  = "bachelor"
            });

            model.Cycles.Add(new SelectListItem()
            {
                Value = "master",
                Text  = "master"
            });

            model.Cycles.Add(new SelectListItem()
            {
                Value = "doctoral",
                Text  = "doctoral"
            });

            model.Cycles.Add(new SelectListItem()
            {
                Value = "other",
                Text  = "other"
            });

            return(model);
        }