Exemplo n.º 1
0
        // GET: Admin/LecturesAdmin/Create
        public ActionResult Create()
        {
            LectureViewCreate lectureViewCreate = new LectureViewCreate(
                db.Identities.Where(x => x.Authority == 0).Select(x => new { Value = x.Id, Text = x.Name + " " + x.Surname }),
                db.Departmants.Select(x => new { Value = x.Id, Text = x.Name }));

            return(View(lectureViewCreate));
        }
Exemplo n.º 2
0
        public async Task <ActionResult> Create(LectureViewCreate lectureViewCreate)
        {
            Lecture lecture = new Lecture();

            lecture.Name       = lectureViewCreate.Name;
            lecture.Capacity   = lectureViewCreate.Capacity;
            lecture.term       = lectureViewCreate.term;
            lecture.MyProperty = lectureViewCreate.MyProperty;
            lecture.instructer = db.Identities.Find(Convert.ToInt32(lectureViewCreate.instructer));

            if (ModelState.IsValid)
            {
                db.Lectures.Add(lecture);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            return(View(lecture));
        }