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)); }
// GET: Profile public ActionResult Index() { ExpoesContext expo = new ExpoesContext(); bool exC = expo.Companies.Any(p => p.Email == User.Identity.Name); if (exC == true) { var Usr = expo.Companies.Single(p => p.Email == User.Identity.Name); return(RedirectToAction("Details", "Companies", new { id = Usr.Id })); } bool exU = expo.Users.Any(p => p.Email == User.Identity.Name); if (exU == true) { var Usr = expo.Users.Single(p => p.Email == User.Identity.Name); return(RedirectToAction("Details", "Users", new { id = Usr.ID })); } return(View()); }
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)); }
public ActionResult History(string email) { ExpoesContext expo = new ExpoesContext(); expo.Configuration.ProxyCreationEnabled = false; bool exC = expo.Companies.Any(p => p.Email == email); bool exU = expo.Users.Any(p => p.Email == email); List <HistoryUpload> lista = new List <HistoryUpload>(); if (exU == true) { var list = expo.History.Where(p => p.User.Email == email).ToList(); foreach (History i in list) { HistoryUpload h = new HistoryUpload(); h.ID = i.ID; h.Description = i.Description; h.Wyszukiwanie = i.Search; h.Expo = long.Parse(i.Expo.Id.ToString()); h.User = i.User.ID; lista.Add(h); } } else if (exC == true) { var list = expo.HistoryW.Where(p => p.Company.Email == email).ToList(); foreach (HistoryW i in list) { HistoryUpload h = new HistoryUpload(); h.ID = i.ID; h.Description = i.Description; h.Wyszukiwanie = i.Search; h.Expo = long.Parse(i.Expo.Id.ToString()); h.User = i.Company.Id; lista.Add(h); } } return(Json(lista, JsonRequestBehavior.AllowGet)); }
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)); } }
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)); }
public void Index(string layout) { String text = null; String name = null; String company = null; ExpoesContext expo = new ExpoesContext(); bool exC = expo.Companies.Any(p => p.Email == User.Identity.Name); if (exC == true) { var Usr = expo.Companies.Single(p => p.Email == User.Identity.Name); text = "Wystawca:" + User.Identity.Name; company = Usr.CompanyName; } bool exU = expo.Users.Any(p => p.Email == User.Identity.Name); if (exU == true) { var Usr = expo.Users.Single(p => p.Email == User.Identity.Name); text = "Uczestnik:" + User.Identity.Name; company = ""; name = Usr.ForName + " " + Usr.SurName; } string filename = String.Format("{0}_tempfile.pdf", Guid.NewGuid().ToString("D").ToUpper()); PdfDocument s_document = new PdfDocument(); s_document.Info.Title = "Your QRCode"; s_document.Info.Author = "ExpoApp"; s_document.Info.Subject = "Grenerating your QRCODE"; s_document.Info.Keywords = "QRcode"; PdfPage page = s_document.AddPage(); XGraphics gfx = XGraphics.FromPdfPage(page); // GET: PDF QRCodeGenerator.ECCLevel eccLevel = (QRCodeGenerator.ECCLevel) 1; using (QRCodeGenerator qrGenerator = new QRCodeGenerator()) { using (QRCodeData qrCodeData = qrGenerator.CreateQrCode(text, eccLevel)) { using (QRCode qrCode = new QRCode(qrCodeData)) { Bitmap bitmap = new Bitmap(qrCode.GetGraphic(20, Color.Black, Color.White, true)); //pdf //BitmapSource bitmapSource = // System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap( // bitmap.GetHbitmap(), // IntPtr.Zero, // Int32Rect.Empty, // BitmapSizeOptions.FromEmptyOptions()); //Image i=Image. XImage image = XImage.FromGdiPlusImage((Image)bitmap); XFont font = new XFont("Times New Roman", 20, XFontStyle.Bold); XImage makieta = XImage.FromFile(HttpContext.Server.MapPath("~/Images/Expo/pdf/" + layout)); // Left position in point gfx.DrawImage(makieta, 0, 0, page.Width, page.Height); gfx.DrawImage(image, 120, 215, 75, 75); gfx.DrawImage(image, 120, 640, 75, 75); //gfx.DrawString(, font, XBrushes.Black, // new XRect(0, 0, page.Width, page.Height), //XStringFormats.Center); gfx.DrawString(name, font, XBrushes.Black, new XRect(30, 175, 250, 20), XStringFormats.Center); gfx.DrawString(company, font, XBrushes.Black, new XRect(30, 195, 250, 20), XStringFormats.Center); gfx.DrawString(name, font, XBrushes.Black, new XRect(30, 600, 250, 20), XStringFormats.Center); gfx.DrawString(company, font, XBrushes.Black, new XRect(30, 620, 250, 20), XStringFormats.Center); } } } s_document.Save(HttpContext.Server.MapPath("~/temp/") + filename); Response.ContentType = "application/pdf"; Response.TransmitFile(HttpContext.Server.MapPath("~/temp/") + filename); // ...and start a viewer //return Redirect("E:/temp/" + filename); }
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)); }