コード例 #1
0
        public async Task <IActionResult> PostProjectType([FromBody] ProjectType projectType)
        {
            if (projectType == null)
            {
                throw new ArgumentException($"{nameof(projectType)} can not be null");
            }
            await _service.Add(projectType);

            return(Ok());
        }
コード例 #2
0
        public ActionResult Create(ProjectType projectType)
        {
            if (ModelState.IsValid)
            {
                _projectTypeService.Add(projectType);
                return(RedirectToAction("Index"));
            }

            SetViewBag(projectType);
            return(View(projectType));
        }
コード例 #3
0
        public async Task <IActionResult> PostProjectType([FromBody] ProjectTypeViewModel projectTypeModel)
        {
            if (projectTypeModel == null)
            {
                throw new ArgumentException($"{nameof(projectTypeModel)} can not be null");
            }

            var mapper = new MapperConfiguration(cfg => cfg.CreateMap <ProjectTypeViewModel, ProjectTypeDto>())
                         .CreateMapper();
            var projectDto = mapper.Map <ProjectTypeViewModel, ProjectTypeDto>(projectTypeModel);

            await _service.Add(projectDto);

            return(Ok());
        }
コード例 #4
0
 public IActionResult AddProjectType(ProjectType projectType)
 {
     projectTypeService.Add(projectType);
     return(RedirectToAction("AllProjectType"));
 }
コード例 #5
0
 public IHttpActionResult PostProjectType(ProjectType projectType)
 {
     projectTypeService.Add(projectType);
     return(Ok());
 }