public IHttpActionResult EditChilds(HijoEntity model) { try { using (var ts = new TransactionScope()) { Hijo hijo = new Hijo(); if (model.HijoId.HasValue) { hijo = context.Hijo.FirstOrDefault(x => x.HijoId == model.HijoId); } hijo.NombreCompleto = model.NombreCompleto; hijo.FechaNacimiento = model.FechaNacimiento; context.SaveChanges(); ts.Complete(); } response.Data = "Hijo Actualizada con éxito"; response.Error = false; response.Message = "Success"; return(Ok(response)); } catch (Exception ex) { return(Unauthorized()); } }
public IHttpActionResult AddChilds(HijoEntity model) { try { using (var ts = new TransactionScope()) { Hijo hijo = new Hijo(); if (!model.HijoId.HasValue) { context.Hijo.Add(hijo); hijo.Estado = ConstantHelpers.ESTADO.ACTIVO; hijo.FechaRegistro = DateTime.Now; hijo.PadreId = model.PadreId; } hijo.NombreCompleto = model.NombreCompleto; hijo.FechaNacimiento = model.FechaNacimiento; context.SaveChanges(); ts.Complete(); } response.Data = "Hijo agregado con éxito"; response.Error = false; response.Message = "Success"; return(Ok(response)); } catch (Exception ex) { return(Unauthorized()); } }