コード例 #1
0
        public async Task <int> Insert(EditableStewardessFields createStewardessRequest)
        {
            var entityToUpdate = _mapper.Map <Stewardess>(createStewardessRequest);
            await _unitOfWork.StewardessRepository.Insert(entityToUpdate);

            await _unitOfWork.SaveChangesAsync();

            return(entityToUpdate.Id);
        }
コード例 #2
0
        public async Task <ActionResult> Post([FromBody] EditableStewardessFields createStewardessRequest)
        {
            var insertedId = await _stewardessService.Insert(createStewardessRequest);

            var result = await _stewardessService.GetById(insertedId);

            var url = Url.Link("GetStewardess", new { id = result.Id });

            return(Created(url, result));
        }
コード例 #3
0
        public async Task <bool> Update(int id, EditableStewardessFields updateStewardessRequest)
        {
            var stewardessToUpdate = _mapper.Map <Stewardess>(updateStewardessRequest);

            stewardessToUpdate.Id = id;
            var result = await _unitOfWork.StewardessRepository.Update(stewardessToUpdate);

            await _unitOfWork.SaveChangesAsync();

            return(result);
        }
コード例 #4
0
        public async Task <ActionResult> Put(int id, [FromBody] EditableStewardessFields updateStewardessRequest)
        {
            var success = await _stewardessService.Update(id, updateStewardessRequest);

            if (success)
            {
                return(Ok());
            }

            return(BadRequest());
        }