public ActionResult Create([Bind(Include = "ID,Description")] Section section) { if (ModelState.IsValid) { sectionService.Create(section); return(RedirectToAction("Index")); } return(View(section)); }
public ActionResult Create(Section section) { try { sectionService.Create(section); return(RedirectToAction(nameof(Index))); } catch (ValidationException ex) { ModelState.AddModelError("", ex.Message); return(View(section)); } }
public HttpResponseMessage Create(SectionsAddRequest model) { if (!ModelState.IsValid) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)); } ItemResponse <int> response = new ItemResponse <int>(); string userId = UserService.GetCurrentUserId(); response.Item = _sectionService.Create(userId, model); return(Request.CreateResponse(response)); }
public void Create_CreatingSection_ShouldCreateSection() { // Arrange var entity = new Section { Name = "Test" }; var before = _db.Sections.Count(); // Act _service.Create(entity); _service.Commit(); // Assert Assert.Equal(1, _db.Sections.Count() - before); }
public IActionResult Create(SectionRequest sectionRequest) { var section = new SectionEditDTO { Name = sectionRequest.Name, Open = sectionRequest.Open, GroupId = sectionRequest.GroupId }; var res = SectionService.Create(section, GetUser()); if (res.Code == AccessCode.Succsess) { return(RedirectToAction("Index", new { id = res.Id })); } else { return(Redirect(res.Code)); } }
public IActionResult AddSection([FromBody] SectionDto sectionDto) { var section = _mapper.Map <Section>(sectionDto); //Company company = new Company() //{ // Name = companyDto.Name, // CategoryId = companyDto.CategoryId, // Section = companyDto.Section, // FunctionCode = companyDto.FunctionCode //}; try { _service.Create(section); return(Ok("Records Added Successfully.. ")); } catch (AppException ex) { return(BadRequest(new { message = ex.Message })); } }
public async Task <ActionResult> Create(CreateSectionViewModel sectionViewModel) { var existingCode = await _sectionService.FindByCode(sectionViewModel.Code); if (existingCode == null) { var section = new CreateSectionDto { Code = sectionViewModel.Code, Class = sectionViewModel.Class, Period = sectionViewModel.Period, Professor = sectionViewModel.Professor, Students = sectionViewModel.Students }; await _sectionService.Create(section); return(Ok()); } else { return(BadRequest("Ya existe una seccion con este codigo")); } }
public Core.Dto.Section Post(Core.Dto.Section section) { return(_sectionService.Create(section)); }
public IActionResult Create([FromBody] CreateSectionDTO dto) { _SectionService.Create(dto); return(Ok(GetResponse("Added"))); }