Example #1
0
        public async Task <IActionResult> CreateOrg([FromBody] OrgCreateInput input)
        {
            Orgnazition org = mapper.Map <Orgnazition>(input);

            dbContext.Orgnazitions.Add(org);
            await dbContext.SaveChangesAsync();

            return(CreatedAtRoute("GetOrg", new { id = org.Id }, mapper.Map <OrgOutput>(org)));
        }
Example #2
0
        public async Task <IActionResult> GetOrg([FromRoute] int id)
        {
            Orgnazition org = await dbContext.Orgnazitions.FirstOrDefaultAsync(o => o.Id == id);

            if (org == null)
            {
                return(NotFound(Json(new { Error = "该部门不存在" })));
            }

            OrgOutput orgOutput = mapper.Map <OrgOutput>(org);

            return(new ObjectResult(orgOutput));
        }