public IActionResult activate(int id, [FromBody] costcenter value) { var costcenter = _context.costcenter.Where(c => c.costcenterId == id).FirstOrDefault <costcenter>(); if (costcenter != null) { costcenter.isActive = true; _context.SaveChanges(); return(Ok(costcenter)); } else { return(NotFound()); } }
public IActionResult Post([FromBody] costcenter value) { var costcenter = new costcenter(); costcenter.name = value.name; costcenter.code = value.code; costcenter.isActive = true; if (value.company != null) { costcenter.companyId = value.company.companyId; } _context.costcenter.Add(costcenter); _context.SaveChanges(); var send = _context.costcenter.Include(c => c.company).Where(c => c.costcenterId == costcenter.costcenterId).FirstOrDefault <costcenter>(); return(Ok(send)); }
public IActionResult Put(int id, [FromBody] costcenter value) { var costcenter = _context.costcenter.Where(c => c.costcenterId == id).FirstOrDefault <costcenter>(); if (costcenter != null) { costcenter.name = value.name; costcenter.code = value.code; if (value.company != null) { costcenter.companyId = value.company.companyId; } _context.SaveChanges(); var send = _context.costcenter.Include(c => c.company).Where(c => c.costcenterId == costcenter.costcenterId).FirstOrDefault <costcenter>(); return(Ok(send)); } else { return(NotFound()); } }