Exemplo n.º 1
0
        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());
            }
        }
Exemplo n.º 2
0
        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());
            }
        }