Пример #1
0
        public async Task <IActionResult> Update(ReasonDTO reasonDto, int id)
        {
            var reason = _mapper.Map <Reason>(reasonDto);
            await _reasonService.Update(reason, id);

            return(Ok());
        }
Пример #2
0
        public IActionResult GetById(int id)
        {
            //Reason testThis = _repository.GetById<Reason>(id);


            var item = ReasonDTO.FromReason(_repository.GetById <Reason>(id));

            return(Ok(item));
        }
Пример #3
0
        public IActionResult Put(int id, [FromBody] string value)
        {
            var reason = _repository.GetById <Reason>(id);

            reason.Description         = value;
            reason.LastChangedBy       = "Some User";
            reason.LastChangedDateTime = DateTime.Now;

            _repository.Update(reason);

            return(Ok(ReasonDTO.FromReason(reason)));
        }
Пример #4
0
        public IActionResult Post([FromBody] ReasonDTO item)
        {
            var newReason = new Reason()
            {
                Description         = item.Description,
                LastChangedBy       = "Some User",
                LastChangedDateTime = DateTime.Now
            };

            _repository.Add(newReason);
            return(Ok(ReasonDTO.FromReason(newReason)));
        }
Пример #5
0
 public static Reason Convert(this ReasonDTO reasonDto)
 {
     return(new Reason
     {
         ItemId = reasonDto.ItemId,
         IsDeleted = reasonDto.IsDeleted,
         Updated = reasonDto.Updated,
         CorrectorId = reasonDto.CorrectorId,
         FullName = reasonDto.Name,
         Category = reasonDto.Category
     });
 }
Пример #6
0
 public async Task Add(ReasonDTO reasonDto)
 {
     var reason = _mapper.Map <Reason>(reasonDto);
     await _reasonService.Create(reason);
 }