Exemplo n.º 1
0
        public ActionResult Join(long?id)
        {
            bool exC = db.Companies.Any(p => p.Email == User.Identity.Name);

            if (exC == true)
            {
                var    Expo = db.Expos.Single(p => p.Id == id);
                Invite i    = new Invite()
                {
                    Email  = User.Identity.Name,
                    Expo   = Expo,
                    Status = status.send
                };
                var Usr = db.Companies.Single(p => p.Email == User.Identity.Name);

                Expo.Company.Add(Usr);
                Usr.Expo.Add(Expo);
                db.Entry(Usr).State  = EntityState.Modified;
                db.Entry(Expo).State = EntityState.Modified;
                db.SaveChanges();
            }
            bool exU = db.Users.Any(p => p.Email == User.Identity.Name);

            if (exU == true)
            {
                var Usr  = db.Users.Single(p => p.Email == User.Identity.Name);
                var Expo = db.Expos.Single(p => p.Id == id);
                Expo.Users.Add(Usr);
                Usr.Expo.Add(Expo);
                db.Entry(Usr).State  = EntityState.Modified;
                db.Entry(Expo).State = EntityState.Modified;
                db.SaveChanges();
            }
            return(RedirectToAction("Index"));
        }
Exemplo n.º 2
0
 public ActionResult Edit([Bind(Include = "Id,StartDate,EndDate,Name,Description,Place")] Event events)
 {
     if (ModelState.IsValid)
     {
         db.Entry(events).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(events));
 }
Exemplo n.º 3
0
        // GET: Invites/Details/5
        public ActionResult approve(int id)
        {
            Invite i = db.Invites.Find(id);

            i.Status = status.approved;
            Expo ex = db.Expos.Where(p => p.Invites.Any(s => s.Id == i.Id)).First();

            i.Expo = ex;
            bool exC = db.Companies.Any(p => p.Email == i.Email);

            if (exC == true)
            {
                var Usr = db.Companies.Single(p => p.Email == i.Email);
                ex.Company.Add(Usr);
                Usr.Expo.Add(ex);
                db.Entry(Usr).State = EntityState.Modified;
                db.Entry(ex).State  = EntityState.Modified;
            }
            db.SaveChanges();
            return(RedirectToAction("InviteE", "Invites", new { @id = ex.Id }));
        }