Beispiel #1
0
        public virtual IActionResult RentalAgreementConditionsIdPut([FromRoute] int id, [FromBody] HetRentalAgreementCondition item)
        {
            bool exists = _context.HetRentalAgreementCondition.Any(a => a.RentalAgreementConditionId == id);

            // not found
            if (!exists || id != item.RentalAgreementConditionId)
            {
                return(new NotFoundObjectResult(new HetsResponse("HETS-01", ErrorViewModel.GetDescription("HETS-01", _configuration))));
            }

            // get record
            HetRentalAgreementCondition condition = _context.HetRentalAgreementCondition
                                                    .First(a => a.RentalAgreementConditionId == id);

            condition.ConcurrencyControlNumber = item.ConcurrencyControlNumber;
            condition.Comment       = item.Comment;
            condition.ConditionName = item.ConditionName;

            // save changes
            _context.SaveChanges();

            // return the updated condition record
            condition = _context.HetRentalAgreementCondition.AsNoTracking()
                        .First(a => a.RentalAgreementConditionId == id);

            return(new ObjectResult(new HetsResponse(condition)));
        }
Beispiel #2
0
        public virtual IActionResult RentalAgreementConditionsIdDeletePost([FromRoute] int id)
        {
            bool exists = _context.HetRentalAgreementCondition.Any(a => a.RentalAgreementConditionId == id);

            // not found
            if (!exists)
            {
                return(new NotFoundObjectResult(new HetsResponse("HETS-01", ErrorViewModel.GetDescription("HETS-01", _configuration))));
            }

            // get record
            HetRentalAgreementCondition condition = _context.HetRentalAgreementCondition.AsNoTracking()
                                                    .First(a => a.RentalAgreementConditionId == id);

            _context.HetRentalAgreementCondition.Remove(condition);

            // save changes
            _context.SaveChanges();

            return(new ObjectResult(new HetsResponse(condition)));
        }