Пример #1
0
        public async Task <IActionResult> AddBenefit([FromBody] BenefitsResource BenefitsResource)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var BenefitToAdd = _mapper.Map <BenefitsResource, Benefits>(BenefitsResource);

            _repo.AddBenefits(BenefitToAdd);
            await _unitofwork.CompleteAsync();

            return(StatusCode(201));
        }
Пример #2
0
        public async Task <IActionResult> UpdateBenefits(int id, [FromBody] BenefitsResource benefitsresource)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            Benefits benefits = await _repo.Get(id);

            if (benefits == null)
            {
                return(NotFound());
            }
            _mapper.Map(benefitsresource, benefits);
            await _unitofwork.CompleteAsync();

            return(StatusCode(202));
        }