コード例 #1
0
        public TMSJobSite Add(JobSiteViewModel Vm)
        {
            var entity = _mapper.Map <JobSiteViewModel, TMSJobSite>(Vm);

            _iTMSJobSiteRepository.Add(entity);
            SaveChanges();
            return(entity);
        }
コード例 #2
0
        public IActionResult Add([FromBody] JobSiteViewModel Vm)
        {
            if (!ModelState.IsValid)
            {
                var allErrors = ModelState.Values.SelectMany(v => v.Errors);
                return(new BadRequestObjectResult(new GenericResult(false, allErrors)));
            }
            else
            {
                try
                {
                    _iTMSJobSiteService.Add(Vm);

                    return(new OkObjectResult(new GenericResult(true, "Add success!!!")));
                }
                catch (Exception ex)
                {
                    return(new OkObjectResult(new GenericResult(false, ex.Message)));
                }
            }
        }