コード例 #1
0
 public Subject PrepareSubjectModel(CreateSubjectViewModel subjectViewModel, string userId)
 {
     return(new Subject
     {
         Name = subjectViewModel.Name,
         IsDeleted = false,
         OwnerId = userId,
         DateCreated = DateTime.UtcNow,
         JoinCode = subjectViewModel.JoinCode
     });
 }
コード例 #2
0
        public JsonResult CreateSubject(CreateSubjectViewModel subject)
        {
            var userId       = User.GetLoggedInUserId <string>();
            var subjectModel = _subjectModelFactory.PrepareSubjectModel(subject, userId);

            _subjectService.CreateSubject(subjectModel);

            var userSubjectMappingModel = _subjectModelFactory.PrepareUserSubjectMappingModel(userId, subjectModel.Id);

            _subjectService.CreateUserSubjectMapping(userSubjectMappingModel);

            return(CreateJsonResult(true));
        }
コード例 #3
0
 public ActionResult Create([FromForm] CreateSubjectViewModel subject)
 {
     try
     {
         Subject s = new Subject
         {
             DepartmentId = subject.DepartmentId,
             ESPB         = subject.ESPB,
             Name         = subject.Name
         };
         uow.Subject.Add(s);
         uow.Commit();
         return(RedirectToAction(nameof(Index)));
     }
     catch
     {
         return(RedirectToAction(nameof(Create)));
     }
 }
コード例 #4
0
        // GET: SubjectController/Create
        public ActionResult Create()
        {
            List <SelectListItem> departments = new List <SelectListItem>();

            foreach (Department d in uow.Department.GetAll())
            {
                departments.Add(new SelectListItem {
                    Value = d.DepartmentId.ToString(), Text = d.Name
                });;
            }
            ViewBag.Departments     = departments;
            ViewData["Departments"] = departments;


            CreateSubjectViewModel model = new CreateSubjectViewModel {
                Departments = departments
            };

            return(View(model));
        }