예제 #1
0
        public async Task Update(PlanTypeModel item)
        {
            var itemToUpdate = await _context.PlanType.SingleOrDefaultAsync(r => r.PlanTypeId == item.PlanTypeId);

            if (itemToUpdate != null)
            {
                itemToUpdate.PlanName = item.PlanName;
                //pending node
                await _context.SaveChangesAsync();
            }
        }
        public async Task <IActionResult> Update(int id, [FromBody] PlanTypeModel item)
        {
            if (item == null)
            {
                return(BadRequest());
            }
            var contactObj = await _repository.Find(id);

            if (contactObj == null)
            {
                return(NotFound());
            }
            await _repository.Update(item);

            return(NoContent());
        }
        public async Task <IActionResult> Create([FromBody] PlanTypeModel item)
        {
            if (item.PlanTypeId == 0)
            {
                await _repository.Add(item);

                return(CreatedAtRoute("GetPlanType", new { Controller = "PlanType", id = item.PlanTypeId }, item));
            }
            else
            {
                if (item.PlanTypeId > 0)
                {
                    await _repository.Update(item);
                }
            }
            return(BadRequest());
        }
예제 #4
0
        public async Task Add(PlanTypeModel item)
        {
            await _context.PlanType.AddAsync(item);

            await _context.SaveChangesAsync();
        }