コード例 #1
0
        public ActionResult <CompanyCreateDto> CreateCompany(CompanyCreateDto companyCreateDto)
        {
            // Map Dto to Model
            var companyModel = _mapper.Map <Company>(companyCreateDto);

            _repository.CreateCompany(companyModel);
            _repository.SaveChanges();

            var companyReadDto = _mapper.Map <CompanyReadDto>(companyModel);

            // CreatedAtRoute creates 201 created with specified values.
            return(CreatedAtRoute(nameof(GetCompanyById), new { Id = companyReadDto.Id }, companyReadDto));
        }
コード例 #2
0
ファイル: CompanyController.cs プロジェクト: YongLWei03/EM-2
        public async Task <ActionResult> Add(EM_Company model)
        {
            model.KPIValue   = model.KPIValue.Value * 10000;
            model.ModifyDate = DateTime.Now;
            model.CreateDate = DateTime.Now;
            model.Modifier   = ViewHelp.GetUserName();
            model.Creater    = ViewHelp.GetUserName();
            companyRepo.Add(model);
            var result = companyRepo.SaveChanges();

            if (result > 0)
            {
                return(Json(new { code = 1 }));
            }
            else
            {
                return(Json(new { code = 0, message = "保存失败,请重试" }));
            }
        }