Ejemplo n.º 1
0
 public ActionResult AgregarDonante(Donor donor)
 {
     if (ModelState.IsValid)
     {
         try
         {
             using (var db = new ContaConmigoEntities())
             {
                 Donor don = new Donor();
                 don.UserId                  = 1;
                 don.Name_Don                = donor.Name_Don;
                 don.Last_Name_Don           = donor.Last_Name_Don;
                 don.Last_Date_Blood_Extract = donor.Last_Date_Blood_Extract;
                 don.CityId                  = donor.CityId;
                 don.BloodGroupFactorId      = donor.BloodGroupFactorId;
                 don.CreatedDate             = DateTime.Now;
                 db.Donors.Add(don);
                 db.SaveChanges();
             }
             return(RedirectToAction("ListadoDonantes"));
         }
         catch (RetryLimitExceededException /* dex */)
         {
             //Log the error (uncomment dex variable name and add a line here to write a log.)
             ModelState.AddModelError("", "Imposible guardar los cambios. Intente nuevamente, y si el problema persiste, por favor comuníquese con el Administrador.");
             return(View());
         }
     }
     else
     {
         return(View());
     }
 }
Ejemplo n.º 2
0
        // GET: Donantes
        public ActionResult ListadoDonantes()
        {
            using (ContaConmigoEntities db = new ContaConmigoEntities())
            {
                List <Donor>            donors       = db.Donors.ToList();
                List <City>             cities       = db.Cities.ToList();
                List <Province>         provinces    = db.Provinces.ToList();
                List <GroupFactorBlood> groupFactors = db.GroupFactorBloods.ToList();

                var donorcitype = from d in donors
                                  join c in cities on d.CityId equals c.Id into table1
                                  from c in table1.ToList()
                                  join p in provinces on c.ProvinceId equals p.ProvinceId into table2
                                  from p in table2.ToList()
                                  join b in groupFactors on d.BloodGroupFactorId equals b.GroupFactorBloodId into table3
                                  from b in table3.ToList()
                                  select new CityViewModel
                {
                    DonorsVM           = d,
                    CitiesVM           = c,
                    ProvincesVM        = p,
                    GroupFactorBloodVM = b
                };
                return(View(donorcitype));
            }
        }
Ejemplo n.º 3
0
        public ActionResult Detail(int id)
        {
            //Donor donor = db.Donors.Find(id);
            //int pcia = db.Cities.Find(donor.CityId).ProvinceId;
            //donor.ProvinceDescription = db.Provinces.Find(pcia).ProvinceDescription;
            //donor.CityName = db.Cities.Find(donor.CityId).CityName;
            //return View(donor);
            using (ContaConmigoEntities db = new ContaConmigoEntities())
            {
                List <Donor>            donors       = db.Donors.ToList();
                List <City>             cities       = db.Cities.ToList();
                List <Province>         provinces    = db.Provinces.ToList();
                List <GroupFactorBlood> groupFactors = db.GroupFactorBloods.ToList();

                var donorcitype = from d in donors
                                  join c in cities on d.CityId equals c.Id into table1
                                  where d.DonorId == id
                                  from c in table1.ToList()
                                  join p in provinces on c.ProvinceId equals p.ProvinceId into table2
                                  from p in table2.ToList()
                                  join b in groupFactors on d.BloodGroupFactorId equals b.GroupFactorBloodId into table3
                                  from b in table3.ToList()

                                  select new CityViewModel
                {
                    DonorsVM           = d,
                    CitiesVM           = c,
                    ProvincesVM        = p,
                    GroupFactorBloodVM = b
                };
                return(View(donorcitype));
            }
        }
Ejemplo n.º 4
0
        public ActionResult SignUp()
        {
            ViewBag.Message = "Logueo de Usuario.";
            ContaConmigoEntities db = new ContaConmigoEntities();

            return(View());
        }
Ejemplo n.º 5
0
        public ActionResult SignUp(UserContaConmigo a)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }
            try
            {
                using (var db = new ContaConmigoEntities())
                {
                    db.UserContaConmigoes.Add(a);
                    db.SaveChanges();

                    //Response.StatusCode = (int)HttpStatusCode.OK;
                    return(RedirectToAction("Index"));
                }
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", "Error al agregar el usuario " + ex.Message);
                return(View());
            }
        }