コード例 #1
0
        public ActionResult DeleteConfirmed()
        {
            ExpoesContext expo = new ExpoesContext();
            bool          exC  = expo.Companies.Any(p => p.Email == User.Identity.Name);

            if (exC == true)
            {
                var Usr = expo.Companies.Remove(expo.Companies.Single(p => p.Email == User.Identity.Name));
                AuthenticationManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie);
                UserManager.Delete(UserManager.Users.Single(p => p.UserName == User.Identity.Name));
                expo.SaveChanges();
                return(RedirectToAction("Index", "Home"));
            }
            bool exU = expo.Users.Any(p => p.Email == User.Identity.Name);

            if (exU == true)
            {
                var Usr = expo.Users.Remove(expo.Users.Single(p => p.Email == User.Identity.Name));
                AuthenticationManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie);
                UserManager.Delete(UserManager.Users.Single(p => p.UserName == User.Identity.Name));
                expo.SaveChanges();
                return(RedirectToAction("Index", "Home"));
            }
            return(RedirectToAction("Index", "Home"));
        }
コード例 #2
0
        // GET: Histories/Create
        public ActionResult Create(long?id)
        {
            HistoryW h = new HistoryW();

            h.Expo        = db.Expos.Single(p => p.Id == id);
            h.Company     = db.Companies.Single(p => p.Email == User.Identity.Name);
            h.Search      = "Wystawca:[email protected]";
            h.Description = "Reklama";
            db.HistoryW.Add(h);
            db.SaveChanges();
            return(RedirectToAction("List"));
        }
コード例 #3
0
        public ActionResult Create([Bind(Include = "Id,StartDate,EndDate,Name,Description,Place")] Event events, int expoid)
        {
            if (ModelState.IsValid)
            {
                Expo ex = db.Expos.Find(expoid);
                db.Events.Add(events);
                db.SaveChanges();
                ex.Events.Add(events);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(events));
        }
コード例 #4
0
 public ActionResult Create([Bind(Include = "ID,Email,ForName,SurName,Photo,Phone,Country,Language,CompanyName")] User user)
 {
     /*if (ModelState.IsValid)
      * {
      *  db.Entry(user).State = EntityState.Modified;
      *  db.SaveChanges();
      *  return RedirectToAction("Index");
      * }
      * return View(user);*/
     try
     {
         ExpoesContext      expo = new ExpoesContext();
         var                c    = expo.Users.Single(p => p.Email == User.Identity.Name);
         HttpPostedFileBase file = Request.Files["Photos"];
         if (file != null && file.ContentLength > 0)
         {
             var Filename = System.Guid.NewGuid().ToString() + ".jpg";
             c.Photo = Filename;
             file.SaveAs(HttpContext.Server.MapPath("~/Images/User/") + Filename);
         }
         UpdateModel(c);
         expo.SaveChanges();
         HttpContext.GetOwinContext().Authentication.SignOut(DefaultAuthenticationTypes.ApplicationCookie);
         //await AuthenticationManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie);
         return(RedirectToAction("Login", "Account"));
     }
     catch (Exception exc)
     {
         return(View(user));
     }
 }
コード例 #5
0
 public ActionResult Edit([Bind(Include = "ID,Email,ForName,SurName,Photo,Phone,Country,Language,CompanyName")] User user)
 {
     /*if (ModelState.IsValid)
      * {
      *  db.Entry(user).State = EntityState.Modified;
      *  db.SaveChanges();
      *  return RedirectToAction("Index");
      * }
      * return View(user);*/
     try
     {
         ExpoesContext      expo = new ExpoesContext();
         var                c    = expo.Users.Single(p => p.ID == user.ID);
         HttpPostedFileBase file = Request.Files["Photos"];
         if (file != null && file.ContentLength > 0)
         {
             if ((System.IO.File.Exists(HttpContext.Server.MapPath("~/Images/User/") + c.Photo)))
             {
                 System.IO.File.Delete(HttpContext.Server.MapPath("~/Images/User/") + c.Photo);
             }
             var Filename = System.Guid.NewGuid().ToString() + ".jpg";
             c.Photo = Filename;
             file.SaveAs(HttpContext.Server.MapPath("~/Images/User/") + Filename);
         }
         UpdateModel(c);
         expo.SaveChanges();
         return(RedirectToAction("Index"));
     }
     catch (Exception exc)
     {
         return(View(user));
     }
 }
コード例 #6
0
        public ActionResult EditProfileUser(string Email, string ForName, string SurName, long Phone, string Nationality)
        {
            ExpoesContext expo  = new ExpoesContext();
            var           check = expo.Users.Any(p => p.Email == Email);

            if (check == false)
            {
                var c = new User()
                {
                    Email       = Email,
                    ForName     = ForName,
                    SurName     = SurName,
                    Phone       = Phone,
                    Nationality = nationality.Polish,
                };
                expo.Users.Add(c);
            }
            else
            {
                var c = expo.Users.Single(p => p.Email == Email);
                c.Email       = Email;
                c.ForName     = ForName;
                c.SurName     = SurName;
                c.Phone       = Phone;
                c.Nationality = nationality.Polish;
                UpdateModel(c);
            }
            expo.SaveChanges();
            var data = new { AccountChanged = true, UnValid = "" };

            return(Json(data, JsonRequestBehavior.AllowGet));
        }
コード例 #7
0
 public ActionResult Create([Bind(Include = "Id,Email,Forname,Surname")] promoter promoter)
 {
     /*if (ModelState.IsValid)
      * {
      *  db.Promoters.Add(promoter);
      *  db.SaveChanges();
      *  return RedirectToAction("Index");
      * }
      *
      * return View(promoter);*/
     try
     {
         ExpoesContext expo = new ExpoesContext();
         var           c    = expo.Promoters.Single(p => p.Email == User.Identity.Name);
         UpdateModel(c);
         expo.SaveChanges();
         HttpContext.GetOwinContext().Authentication.SignOut(DefaultAuthenticationTypes.ApplicationCookie);
         //await AuthenticationManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie);
         return(RedirectToAction("Login", "Account"));
     }
     catch (Exception exc)
     {
         return(View(promoter));
     }
 }
コード例 #8
0
        public ActionResult DeleteConfirmed(long id)
        {
            Company company = db.Companies.Find(id);

            db.Companies.Remove(company);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #9
0
        public ActionResult DeleteConfirmed(long id)
        {
            promoter promoter = db.Promoters.Find(id);

            db.Promoters.Remove(promoter);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #10
0
        public ActionResult EditProfileCompany(string Email, string ContactEmail, string CompanyName,
                                               string CompanyFullName, string CompanyAbout, string ProductsAbout, long Phone, long UserPhone, string Facebook, string Instagram, string Snapchat,
                                               string Youtube, string www, string Adress, string NIP, string Forname_And_Surname, string Trade)
        {
            ExpoesContext expo  = new ExpoesContext();
            var           check = expo.Companies.Any(p => p.Email == Email);

            if (check == false)
            {
                var c = new Company()
                {
                    Email               = Email,
                    ContactEmail        = ContactEmail,
                    CompanyName         = CompanyName,
                    CompanyFullName     = CompanyFullName,
                    CompanyAbout        = CompanyAbout,
                    ProductsAbout       = ProductsAbout,
                    Phone               = Phone,
                    UserPhone           = UserPhone,
                    Adress              = Adress,
                    ForName_And_SurName = Forname_And_Surname,
                    Facebook            = Facebook,
                    Instagram           = Instagram,
                    Snapchat            = Snapchat,
                    NIP     = NIP,
                    Youtube = Youtube,
                    www     = www,
                    Trade   = trade.Banking
                };
                expo.Companies.Add(c);
            }
            else
            {
                var c = expo.Companies.Single(p => p.Email == Email);
                c.Email               = Email;
                c.ContactEmail        = ContactEmail;
                c.CompanyName         = CompanyName;
                c.CompanyFullName     = CompanyFullName;
                c.CompanyAbout        = CompanyAbout;
                c.ProductsAbout       = ProductsAbout;
                c.Phone               = Phone;
                c.UserPhone           = UserPhone;
                c.Adress              = Adress;
                c.ForName_And_SurName = Forname_And_Surname;
                c.Facebook            = Facebook;
                c.Instagram           = Instagram;
                c.Snapchat            = Snapchat;
                c.NIP     = NIP;
                c.Youtube = Youtube;
                c.www     = www;
                UpdateModel(c);
            }
            expo.SaveChanges();
            var data = new { AccountChanged = true, UnValid = "" };

            return(Json(data, JsonRequestBehavior.AllowGet));
        }
コード例 #11
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"));
        }
コード例 #12
0
 public ActionResult Edit([Bind(Include = "Id,Email,Forname,Surname")] promoter promoter)
 {
     try
     {
         ExpoesContext expo = new ExpoesContext();
         var           c    = expo.Promoters.Single(p => p.Id == promoter.Id);
         UpdateModel(c);
         expo.SaveChanges();
         return(RedirectToAction("Index"));
     }
     catch (Exception exc)
     {
         return(View(promoter));
     }
 }
コード例 #13
0
        public ActionResult Add([Bind(Include = "ID")] Files files)
        {
            if (ModelState.IsValid)
            {
                HttpPostedFileBase Fileq = Request.Files["Filek"];
                if (Fileq != null && Fileq.ContentLength > 0)
                {
                    Char     delimiter = '.';
                    string[] pom       = Fileq.FileName.ToString().Split(delimiter);
                    var      Filename  = System.Guid.NewGuid().ToString() + "." + pom[1];
                    Fileq.SaveAs(HttpContext.Server.MapPath("~/Images/Company/Files/") + Filename);
                    files.File = Filename;
                    files.Name = pom[0];
                }

                Company c = db.Companies.Single(p => p.Email == User.Identity.Name);
                c.Files.Add(files);
                db.Files.Add(files);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(files));
        }
コード例 #14
0
        public ActionResult insertUExpo(long Userid, int Expoid)
        {
            ExpoesContext db  = new ExpoesContext();
            bool          exC = db.Users.Any(p => p.ID == Userid);

            if (exC == true)
            {
                var Usr  = db.Users.Single(p => p.ID == Userid);
                var Expo = db.Expos.Single(p => p.Id == Expoid);
                Expo.Users.Add(Usr);
                Usr.Expo.Add(Expo);
                db.SaveChanges();
            }
            var data = new { JoinedU = true };

            return(Json(data, JsonRequestBehavior.AllowGet));
        }
コード例 #15
0
        public ActionResult insertHistoryC(string Search, string Description, long Companyid, int Expoid)
        {
            ExpoesContext expo = new ExpoesContext();
            HistoryW      h    = new HistoryW()
            {
                Search      = Search,
                Description = Description,
                Company     = expo.Companies.Single(p => p.Id == Companyid),
                Expo        = expo.Expos.Single(p => p.Id == Expoid)
            };

            expo.HistoryW.Add(h);
            expo.SaveChanges();
            expo.Configuration.ProxyCreationEnabled = false;
            var data = new { saved = true };

            return(Json(data, JsonRequestBehavior.AllowGet));
        }
コード例 #16
0
        public async System.Threading.Tasks.Task <JsonResult> Register(String Email, String Password, String UserType)
        {
            RegisterViewModelMobile model = new RegisterViewModelMobile()
            {
                Email           = Email,
                Password        = Password,
                ConfirmPassword = Password,
                AccountType     = UserType
            };
            var user = new ApplicationUser {
                UserName = model.Email, Email = model.Email
            };
            var result = HttpContext.GetOwinContext().GetUserManager <ApplicationUserManager>().CreateAsync(user, model.Password);

            if (model.AccountType.Contains("User"))
            {
                await HttpContext.GetOwinContext().GetUserManager <ApplicationUserManager>().AddToRoleAsync(user.Id, "User");

                User u = new Models.User {
                    Email = model.Email
                };
                ExpoesContext expo = new ExpoesContext();
                expo.Users.Add(u);
                expo.SaveChanges();
                var data = new { AccountCreated = true, UnValid = "" };
                return(Json(data, JsonRequestBehavior.AllowGet));
            }
            if (model.AccountType.Contains("Company"))
            {
                await HttpContext.GetOwinContext().GetUserManager <ApplicationUserManager>().AddToRoleAsync(user.Id, "Wystawca");

                Company c = new Models.Company {
                    Email = model.Email
                };
                ExpoesContext expo = new ExpoesContext();
                expo.Companies.Add(c);
                expo.SaveChanges();
                var data = new { AccountCreated = true, UnValid = "" };
                return(Json(data, JsonRequestBehavior.AllowGet));
            }
            var data1 = new { AccountCreated = false, UnValid = "Email" };

            return(Json(data1, JsonRequestBehavior.AllowGet));
        }
コード例 #17
0
        public ActionResult UploadPhotoUser()
        {
            ExpoesContext      expo  = new ExpoesContext();
            string             email = Request["Email"].ToString();
            var                c     = expo.Users.Single(p => p.Email == email);
            HttpPostedFileBase file  = Request.Files["photod"];

            if (file != null && file.ContentLength > 0)
            {
                var Filename = System.Guid.NewGuid().ToString() + ".jpg";
                c.Photo = Filename;
                file.SaveAs(HttpContext.Server.MapPath("~/Images/User/") + Filename);
            }
            UpdateModel(c);
            expo.SaveChanges();
            var data = new { UploadPhoto = email, Uploadstat = c.Photo };

            return(Json(data, JsonRequestBehavior.AllowGet));
        }
コード例 #18
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 }));
        }
コード例 #19
0
        public async Task <ActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser {
                    UserName = model.Email, Email = model.Email
                };
                var result = await UserManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    String t = Request["User"].ToString();
                    //Console.WriteLine(t);
                    await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false);

                    if (t.Contains("Uczestnik"))
                    {
                        UserManager.AddToRole(user.Id, "User");
                        User u = new Models.User {
                            Email = model.Email
                        };
                        ExpoesContext expo = new ExpoesContext();
                        expo.Users.Add(u);
                        expo.SaveChanges();
                        return(RedirectToAction("Create", "Users", new { id = u.ID }));
                    }
                    if (t.Contains("Wystawca"))
                    {
                        UserManager.AddToRole(user.Id, "Wystawca");
                        Company c = new Models.Company {
                            Email = model.Email
                        };
                        ExpoesContext expo = new ExpoesContext();
                        expo.Companies.Add(c);
                        expo.SaveChanges();
                        return(RedirectToAction("Create", "Companies", new { id = c.Id }));
                    }
                    if (t.Contains("Organizator"))
                    {
                        UserManager.AddToRole(user.Id, "Organizator");
                        promoter p = new Models.promoter {
                            Email = model.Email
                        };
                        ExpoesContext expo = new ExpoesContext();
                        expo.Promoters.Add(p);
                        expo.SaveChanges();
                        return(RedirectToAction("Create", "Promoters", new { id = p.Id }));
                    }
                    // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771
                    // Send an email with this link
                    // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
                    // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                    // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");

                    return(RedirectToAction("Index", "Home"));
                }
                AddErrors(result);
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
コード例 #20
0
        public ActionResult UploadPhotoCompany()
        {
            ExpoesContext      expo  = new ExpoesContext();
            string             email = Request["Email"].ToString();
            var                c     = expo.Companies.Single(p => p.Email == email);
            HttpPostedFileBase logo  = Request.Files["logo"];

            if (logo != null && logo.ContentLength > 0)
            {
                var Filename = System.Guid.NewGuid().ToString() + ".jpg";
                c.CompanyLogo = Filename;
                logo.SaveAs(HttpContext.Server.MapPath("~/Images/Company/") + Filename);
            }
            HttpPostedFileBase stand = Request.Files["stand"];

            if (stand != null && stand.ContentLength > 0)
            {
                var Filename = System.Guid.NewGuid().ToString() + ".jpg";
                c.StandPhoto = Filename;
                stand.SaveAs(HttpContext.Server.MapPath("~/Images/Company/") + Filename);
            }
            HttpPostedFileBase photo1 = Request.Files["photo1"];

            if (photo1 != null && photo1.ContentLength > 0)
            {
                var Filename = System.Guid.NewGuid().ToString() + ".jpg";
                c.Photo1 = Filename;
                photo1.SaveAs(HttpContext.Server.MapPath("~/Images/Company/") + Filename);
            }
            HttpPostedFileBase photo2 = Request.Files["photo2"];

            if (photo2 != null && photo2.ContentLength > 0)
            {
                var Filename = System.Guid.NewGuid().ToString() + ".jpg";
                c.Photo2 = Filename;
                photo2.SaveAs(HttpContext.Server.MapPath("~/Images/Company/") + Filename);
            }
            HttpPostedFileBase photo3 = Request.Files["photo3"];

            if (photo3 != null && photo3.ContentLength > 0)
            {
                var Filename = System.Guid.NewGuid().ToString() + ".jpg";
                c.Photo3 = Filename;
                photo3.SaveAs(HttpContext.Server.MapPath("~/Images/Company/") + Filename);
            }
            HttpPostedFileBase photo4 = Request.Files["photo4"];

            if (photo4 != null && photo4.ContentLength > 0)
            {
                var Filename = System.Guid.NewGuid().ToString() + ".jpg";
                c.Photo4 = Filename;
                photo4.SaveAs(HttpContext.Server.MapPath("~/Images/Company/") + Filename);
            }
            HttpPostedFileBase photo5 = Request.Files["photo5"];

            if (photo5 != null && photo5.ContentLength > 0)
            {
                var Filename = System.Guid.NewGuid().ToString() + ".jpg";
                c.Photo5 = Filename;
                photo5.SaveAs(HttpContext.Server.MapPath("~/Images/Company/") + Filename);
            }
            UpdateModel(c);
            expo.SaveChanges();
            var data = new { UploadPhoto = email, Uploadstat = "Upload" };

            return(Json(data, JsonRequestBehavior.AllowGet));
        }
コード例 #21
0
 public ActionResult Create([Bind(Include = "Id,Email,CompanyName,CompanyFullName,CompanyAbout,ProductsAbout,CompanyLogo,StandPhoto,Photo1,Photo2,Photo3,Photo4,Photo5,Facebook,Instagram,Snapchat,Youtube,Phone,ContactEmail,www,Adress,NIP,ForName_And_SurName,UserPhone,User_ID")] Company company)
 {
     /* if (ModelState.IsValid)
      * {
      *  db.Entry(company).State = EntityState.Modified;
      *  db.SaveChanges();
      *  return RedirectToAction("Index");
      * }*/
     try
     {
         ExpoesContext      expo  = new ExpoesContext();
         Company            c     = expo.Companies.Single(p => p.Email == User.Identity.Name);
         HttpPostedFileBase logos = Request.Files["Logo"];
         if (logos != null && logos.ContentLength > 0)
         {
             Char     delimiter = '.';
             string[] pom       = logos.FileName.ToString().Split(delimiter);
             var      Filename  = System.Guid.NewGuid().ToString() + "." + pom[1];
             c.CompanyLogo = Filename;
             logos.SaveAs(HttpContext.Server.MapPath("~/Images/Company/") + Filename);
         }
         HttpPostedFileBase Stand = Request.Files["Stand"];
         if (Stand != null && Stand.ContentLength > 0)
         {
             var Filename = System.Guid.NewGuid().ToString() + ".jpg";
             c.StandPhoto = Filename;
             Stand.SaveAs(HttpContext.Server.MapPath("~/Images/Company/") + Filename);
         }
         HttpPostedFileBase Photo = Request.Files["Photos1"];
         if (Photo != null && Photo.ContentLength > 0)
         {
             var Filename = System.Guid.NewGuid().ToString() + ".jpg";
             c.Photo1 = Filename;
             Photo.SaveAs(HttpContext.Server.MapPath("~/Images/Company/") + Filename);
         }
         HttpPostedFileBase Photo2 = Request.Files["Photos2"];
         if (Photo2 != null && Photo2.ContentLength > 0)
         {
             var Filename = System.Guid.NewGuid().ToString() + ".jpg";
             c.Photo2 = Filename;
             Photo2.SaveAs(HttpContext.Server.MapPath("~/Images/Company/") + Filename);
         }
         HttpPostedFileBase Photo3 = Request.Files["Photos3"];
         if (Photo3 != null && Photo3.ContentLength > 0)
         {
             var Filename = System.Guid.NewGuid().ToString() + ".jpg";
             c.Photo3 = Filename;
             Photo3.SaveAs(HttpContext.Server.MapPath("~/Images/Company/") + Filename);
         }
         HttpPostedFileBase Photo4 = Request.Files["Photos4"];
         if (Photo4 != null && Photo4.ContentLength > 0)
         {
             var Filename = System.Guid.NewGuid().ToString() + ".jpg";
             c.Photo4 = Filename;
             Photo4.SaveAs(HttpContext.Server.MapPath("~/Images/Company/") + Filename);
         }
         HttpPostedFileBase Photo5 = Request.Files["Photos5"];
         if (Photo5 != null && Photo5.ContentLength > 0)
         {
             var Filename = System.Guid.NewGuid().ToString() + ".jpg";
             c.Photo5 = Filename;
             Photo5.SaveAs(HttpContext.Server.MapPath("~/Images/Company/") + Filename);
         }
         UpdateModel(c);
         expo.SaveChanges();
         HttpContext.GetOwinContext().Authentication.SignOut(DefaultAuthenticationTypes.ApplicationCookie);
         //await AuthenticationManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie);
         return(RedirectToAction("Login", "Account"));
     }
     catch (Exception exc)
     {
         return(View(company));
     }
 }