コード例 #1
0
 public ActionResult Create([Bind(Include = "ID,Description")] Section section)
 {
     if (ModelState.IsValid)
     {
         sectionService.Create(section);
         return(RedirectToAction("Index"));
     }
     return(View(section));
 }
コード例 #2
0
 public ActionResult Create(Section section)
 {
     try
     {
         sectionService.Create(section);
         return(RedirectToAction(nameof(Index)));
     }
     catch (ValidationException ex)
     {
         ModelState.AddModelError("", ex.Message);
         return(View(section));
     }
 }
コード例 #3
0
        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));
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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));
            }
        }
コード例 #6
0
        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 }));
            }
        }
コード例 #7
0
        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"));
            }
        }
コード例 #8
0
 public Core.Dto.Section Post(Core.Dto.Section section)
 {
     return(_sectionService.Create(section));
 }
コード例 #9
0
 public IActionResult Create([FromBody] CreateSectionDTO dto)
 {
     _SectionService.Create(dto);
     return(Ok(GetResponse("Added")));
 }