Esempio n. 1
0
        public IActionResult Post([FromBody] FilialCollaborator item)
        {
            if (item == null)
            {
                return(BadRequest());
            }

            item.Id = _context.FilialCollaborators.Count() + 1;
            _context.FilialCollaborators.Add(item);
            _context.SaveChanges();

            return(CreatedAtRoute("GetFilialCollaborator", new { id = item.Id }, item));
        }
Esempio n. 2
0
        public IActionResult Update(long id, [FromBody] FilialCollaborator item)
        {
            if (item == null || item.Id != id)
            {
                return(BadRequest());
            }

            var filialCollaborator = _context.FilialCollaborators.FirstOrDefault(t => t.Id == id);

            if (filialCollaborator == null)
            {
                return(NotFound());
            }

            filialCollaborator.CollaboratorId = item.CollaboratorId;
            filialCollaborator.FilialId       = item.FilialId;

            _context.FilialCollaborators.Update(filialCollaborator);
            _context.SaveChanges();
            return(new NoContentResult());
        }