public Service PatchUpdate(int id, ServiceRaw current)
        {
            var actual = _context.Service.Single(x => x.Id == id);

            if (current.PeriodType != default)
            {
                actual.PeriodType = current.PeriodType;
            }

            if (current.AccountId != default)
            {
                actual.AccountId = current.AccountId;
            }


            if (current.Name != default)
            {
                actual.Name = current.Name;
            }

            if (current.Price != default)
            {
                actual.Price = current.Price;
            }

            if (current.StartDate != default)
            {
                actual.StartDate = current.StartDate;
            }

            _context.SaveChanges();

            return(actual);
        }
Esempio n. 2
0
        public ActionResult <Account> PatchAccount([FromODataUri] int key, [FromBody] ServiceRaw itemRaw)
        {
            if (!ModelState.IsValid)
            {
                BadRequest(ModelState);
            }


            _repository.PatchUpdate(key, itemRaw);

            return(Ok(itemRaw));
        }