Exemplo n.º 1
0
        public DonorInfo GetDonorInfoById(int id)
        {
            DonorInfo mod = new DonorInfo();

            try
            {
                //mod = _context.DonorInfo.Find(id);
                mod = _context.DonorInfo.Include(a => a.DonationDetails).Where(a => a.Id == id).FirstOrDefault();
                _context.Entry(mod).State = EntityState.Detached;
                return(mod);
            }
            catch (Exception ex)
            {
                mod = null;
                mod.AddErrorMessage(ex.Message);
            }
            return(mod);
        }
Exemplo n.º 2
0
 public DonorInfo AddDonorInfo(DonorInfo mod)
 {
     try
     {
         if (mod.Id == 0)
         {
             _context.DonorInfo.Add(mod);
         }
         else
         {
             _context.Entry(mod).State = EntityState.Modified;
             _context.Set <DonorInfo>().Attach(mod);
         }
         _context.SaveChanges();
     }
     catch (Exception ex)
     {
         mod.HasError = true;
         mod.AddErrorMessage(ex.Message);
     }
     return(mod);
 }