public ActionResult CreateSection(SectionCreateViewModel viewModel) { if (ModelState.IsValid) { var moderator = _userService.GetUserEntityByLogin(viewModel.SettedModeratorLogin); if (moderator.Roles.All(r => r.RoleName != Role.Moderator.ToString())) { moderator.Roles.Add(new RoleEntity() { RoleName = Role.Moderator.ToString(), Id = (int)Role.Moderator }); } _userService.UpdateUser(moderator); viewModel.UserRefId = moderator.Id; var bllSection = viewModel.ToBllSectionEntity(); _sectionService.CreateSection(bllSection); return(RedirectToAction("AllSections", "Admin")); } viewModel.UsersLogin = _userService.GetAllUserEntities() .Where(u => !u.IsBlocked) .Select(u => new SelectListItem() { Value = u.Login, Text = u.Login }); return(View(viewModel)); }
public ActionResult Create(CreateSectionViewModel createSection) { var createSectionDto = Mapper.Map <CreateSectionDto>(createSection); _sectionService.CreateSection(createSectionDto); return(RedirectToAction("Item", "SectionList", new { Id = createSection.SectionListId })); }
public ActionResult AddLevelInCourse(Nivel selectedLevel, int courseId) { string uid = User.Identity.GetUserId(); if (!courseService.CanUserModifyCourseLevelsAndTypes(uid, courseId)) { this.AddNotification("Ju nuk mund te shtoni nivele ne kursin me id:" + courseId, NotificationType.ERROR); return(RedirectToAction("CourseLevels", "Course", new { @id = courseId })); } if (selectedLevel.Id == 0) { this.AddNotification("Opsioni qe ju zgjodhet nuk eshte i vlefshem.", NotificationType.ERROR); return(RedirectToAction("AddLevelInCourse", "Level", new { @id = courseId })); } var levelToAdd = levelService.GetLevelById(selectedLevel.Id); if (levelToAdd == null) { return(new HttpNotFoundResult()); } KursNivelTip newSection = new KursNivelTip() { KursiId = courseId, NiveliId = selectedLevel.Id }; sectionService.CreateSection(newSection); this.AddNotification(levelToAdd.Emri + " u shtua me sukses ne kursin " + TempData["Course"], NotificationType.SUCCESS); return(RedirectToAction("CourseLevels", "Course", new { @id = courseId })); }
public async Task <IActionResult> AddSection([FromBody] Section section) { await _service.CreateSection(section); await _service.Save(); return(Ok()); }
public IActionResult Create(SectionViewModel vm) { if (ModelState.IsValid) { var section = _mapper.Map <Section>(vm); _sectionService.CreateSection(section); return(RedirectToAction("List", "Section")); } return(View(vm)); }
public IActionResult Create(SectionViewModel sectionVM) { if (ModelState.IsValid) { Section section = new Section(); section.Name = sectionVM.Name; section.AddedBy = "CEVDET"; section.AddedDate = DateTime.Now; section.ModifiedBy = "CEVDET"; section.ModifiedDate = DateTime.Now; sectionService.CreateSection(section); sectionService.SaveSection(); return(RedirectToAction("Index", "Section")); } return(View(sectionVM)); }
public ActionResult Create(CreateSectionViewData model) { model.Groups = groupService.GetGroups(new GetGroupDataListRequest()).DataList.ToList(); if (ModelState.IsValid) { BaseReply reply = sectionService.CreateSection(new CreateSectionRequest { Subject = model.Subject, Enabled = model.Enabled, GroupId = model.GroupId }); if (!reply.Success) { ModelState.MergeError(reply.ErrorState); } else { return(this.RedirectToAction(s => s.Index(model.GroupId))); } } return(View(model)); }
public IActionResult CreateSection([FromBody] SectionDTO value) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } try { //var idToken = HttpContext.GetTokenAsync(JwtBearerDefaults.AuthenticationScheme, "access_token"); //var token = idToken.Result; var section = _sectionService.CreateSection(value, ""); if (section != null) { return(Ok(section)); } return(BadRequest(new { message = "Cannot Create Section" })); } catch (Exception e) { return(BadRequest(e)); } }
public ActionResult AddSection(SectionViewModel model) { model.DateAdded = DateTime.Now; service.CreateSection(model.ToBllSection()); return(RedirectToAction("Index", "Home")); }
// POST api/<controller> public void Post(CreateSectionViewModel createSectionView) { var creaeSectionDto = Mapper.Map <CreateSectionDto>(createSectionView); _sectionService.CreateSection(creaeSectionDto); }
public ActionResult AddSection(SectionViewModel model) { sectionService.CreateSection(model.ToBllSection()); return(RedirectToAction("WorkWithSections", "Section")); }