public async Task <bool> SendPasswordRecoveryMail(string id, string email) { try { //var provider = new DpapiDataProtectionProvider("http://newtemp.apphb.com/"); //UserManager.UserTokenProvider = new DataProtectorTokenProvider<ApplicationUser, string>(provider.Create("UserToken")) // as IUserTokenProvider<ApplicationUser, string>; var code = await UserManager.GeneratePasswordResetTokenAsync(id); var callbackUrl = Url.Action( "ResetPassword", "Account", new { userId = id, code = code }, protocol: Request.Url.Scheme, defaultPort: true); // ElectronicsController.sendEmail(email, "Recover your password", "Recover your password by clicking <a href=\"" + callbackUrl + "\">here</a> OR " + callbackUrl); string Body = System.IO.File.ReadAllText(Server.MapPath("/Views/Admin/Email/PasswordRecovery.html")); Body = Body.Replace("ResetPasswordLink", callbackUrl); ElectronicsController.sendEmail(email, "Recover your password", Body); } catch (Exception e) { string s = e.ToString(); ElectronicsController.sendEmail(email, "Recover your password", s); } return(true); }
public ActionResult Edit([Bind(Include = "Id,category,subCategory,postedBy,time,title,description")] Question question) { if (ModelState.IsValid) { SaveQuestionTags(Request["tags"], question, true); db.Entry(question).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbEntityValidationException e) { string s = e.ToString(); List <string> errorMessages = new List <string>(); foreach (DbEntityValidationResult validationResult in e.EntityValidationErrors) { string entityName = validationResult.Entry.Entity.GetType().Name; foreach (DbValidationError error in validationResult.ValidationErrors) { errorMessages.Add(entityName + "." + error.PropertyName + ": " + error.ErrorMessage); } } } return(RedirectToAction("Details", new { id = question.Id, title = ElectronicsController.URLFriendly(question.title) })); } return(View(question)); }
public async Task <IHttpActionResult> DeleteCompany(int id) { Company company = await db.Companies.FindAsync(id); if (company == null) { return(NotFound()); } IAmazonS3 client; var logoExtension = company.logoextension; if (logoExtension != null) { logoExtension = logoExtension.Trim(); } DeleteObjectsRequest multiObjectDeleteRequest = new DeleteObjectsRequest(); multiObjectDeleteRequest.BucketName = _bucketName; multiObjectDeleteRequest.AddKey(_companyFoler + "/" + company.Id + "/logo" + logoExtension, null); var userId = User.Identity.GetUserId(); var email = company.AspNetUser.UserName; var status = db.AspNetUsers.Find(userId).status; if (status == "admin") { if (userId != company.createdBy) { string Body = System.IO.File.ReadAllText(HttpContext.Current.Server.MapPath("/Views/Admin/Email/DeletePageAlert.html")); Body = Body.Replace("#CompanyTitle#", company.title); ElectronicsController.sendEmail(email, "Your Busniess page is deleted by admin!", Body); } } try { AmazonS3Config config = new AmazonS3Config(); config.ServiceURL = "https://s3.amazonaws.com/"; using (client = Amazon.AWSClientFactory.CreateAmazonS3Client( _awsAccessKey, _awsSecretKey, config)) { client.DeleteObjects(multiObjectDeleteRequest); } } catch (Exception e) { string s = e.ToString(); } db.Companies.Remove(company); await db.SaveChangesAsync(); return(Ok(company)); }
public ActionResult Create(string category, string subcategory = null) { if (Request.IsAuthenticated) { if (ElectronicsController.checkCategory(category, subcategory)) { ViewBag.category = category; ViewBag.subcategory = subcategory; Ad ad = new Ad(); return(View(ad)); } return(HttpNotFound()); } return(RedirectToAction("Register", "Account")); }
public async Task <IHttpActionResult> SubmitFeedback(Feedback fb) { if (System.Web.HttpContext.Current.User.Identity.IsAuthenticated) { if (ModelState.IsValid) { fb.givenBy = User.Identity.GetUserId(); fb.time = DateTime.UtcNow; db.Feedbacks.Add(fb); await db.SaveChangesAsync(); ElectronicsController.sendEmail("*****@*****.**", "dealkar.pk feedback", "From: " + fb.givenBy + " Time:" + fb.time + " " + fb.description); return(Ok("Done")); } } return(BadRequest()); }
public ActionResult uploadLogo() { int id = int.Parse(Request["id"]); HttpPostedFileBase file = Request.Files["fileInput"]; string extension = System.IO.Path.GetExtension(file.FileName); string newFileName = id + "/logo" + extension; AmazonS3Config config = new AmazonS3Config(); config.ServiceURL = "https://s3.amazonaws.com/"; Amazon.S3.IAmazonS3 s3Client = AWSClientFactory.CreateAmazonS3Client(_awsAccessKey, _awsSecretKey, config); var request2 = new PutObjectRequest() { BucketName = _bucketName, CannedACL = S3CannedACL.PublicRead, //PERMISSION TO FILE PUBLIC ACCESIBLE Key = _folderName + newFileName, InputStream = file.InputStream //SEND THE FILE STREAM }; s3Client.PutObject(request2); var data = db.Companies.Find(id); data.logoextension = extension; db.Entry(data).State = EntityState.Modified; db.SaveChanges(); //string companyFolder = "~/Images/Company/" + id; //if (! System.IO.Directory.Exists(Server.MapPath(companyFolder))) //{ // System.IO.Directory.CreateDirectory(Server.MapPath(companyFolder)); //} ////filename = "temp" + DateTime.UtcNow.Ticks + extension; //file.SaveAs(Server.MapPath(companyFolder + "/logo" + extension )); //var data = db.Companies.Find(id); //data.logoextension = extension; //db.Entry(data).State = EntityState.Modified; //db.SaveChanges(); return(RedirectToAction("Details", "Company", new { id = id, title = ElectronicsController.URLFriendly(data.title) })); }
public ActionResult Create([Bind(Include = "Id,category,subcategory,postedBy,title,description,time,price,isnegotiable")] Ad ad) { if (ModelState.IsValid) { if (Request.IsAuthenticated) { if (!ElectronicsController.checkCategory(ad.category, ad.subcategory)) { return(RedirectToAction("CreateAd", "Home")); } //string tempId = Request["tempId"]; FileName[] fileNames = JsonConvert.DeserializeObject <FileName[]>(Request["files"]); ad = electronicController.MyAd(ad, "Save", ad.category, ad.subcategory); electronicController.PostAdByCompanyPage(ad.Id); //images try { db.SaveChanges(); } catch (Exception e) { string sbs = e.ToString(); } //tags electronicController.SaveTags(Request["tags"], ad); electronicController.ReplaceAdImages(ad, fileNames); //location electronicController.MyAdLocation(Request["city"], Request["popularPlace"], Request["exectLocation"], ad, "Save"); return(RedirectToAction("Details", "Electronics", new { id = ad.Id, title = ElectronicsController.URLFriendly(ad.title) })); } return(RedirectToAction("Register", "Account")); } TempData["error"] = "Only enter those information about which you are asked"; return(View("Create", ad)); }
public async Task <bool> SendMailtoConfirmEmailAddress(string id, string name, string email) { var user = await db.AspNetUsers.FindAsync(id); if (user.EmailConfirmed) { return(false); } try { //var provider = new DpapiDataProtectionProvider("http://newtemp.apphb.com/"); //UserManager.UserTokenProvider = new DataProtectorTokenProvider<ApplicationUser, string>(provider.Create("UserToken")) // as IUserTokenProvider<ApplicationUser, string>; var code = await UserManager.GenerateEmailConfirmationTokenAsync(id); //var callbackUrl = Url.Action( // "ConfirmEmail", "Account", // new { userId = id, code = code }, // protocol: Request.Url.Scheme); var callbackUrl = Url.Action( "ConfirmEmail", "Account", new { userId = id, code = code }, protocol: Request.Url.Scheme, defaultPort: true); // ElectronicsController.sendEmail(email, "Welcome to dealkar.pk - Confirm Email address", "Hello " + name + "!<br/>Confirm your email address by clicking <a href=\"" + callbackUrl + "\">here</a> OR " + callbackUrl); string Body = System.IO.File.ReadAllText(Server.MapPath("/Views/Admin/Email/ConfirmEmail.html")); Body = Body.Replace("ConfirmEmailLink", callbackUrl); ElectronicsController.sendEmail(email, "Welcome to dealkar.pk", Body); } catch (Exception e) { string s = e.ToString(); } return(true); }
public async Task <IHttpActionResult> CreateServiesAd(string title, string tags, string city, string popularPlace, string exectLocation) { ElectronicsController electronicController = new ElectronicsController(); if (User.Identity.IsAuthenticated) { //if (!ElectronicsController.checkCategory(ad.category, ad.subcategory)) //{ // return RedirectToAction("CreateAd", "Home"); //} // FileName[] fileNames = JsonConvert.DeserializeObject<FileName[]>(Request["files"]); Ad ad = new Ad(); ad = electronicController.MyAd(ad, "Save", "Services", null); // electronicController.PostAdByCompanyPage(ad.Id); //images try { db.SaveChanges(); } catch (Exception e) { string sbs = e.ToString(); } //tags // electronicController.SaveTags(Request["tags"], ad); // electronicController.ReplaceAdImages(ad, fileNames); //location electronicController.MyAdLocation(city, popularPlace, exectLocation, ad, "Save"); //return RedirectToAction("Details", "Electronics", new { id = ad.Id, title = ElectronicsController.URLFriendly(ad.title) }); return(Ok("Done")); } return(BadRequest()); }
public async Task <IHttpActionResult> SaveNeedAService(string title, string tags, string city, string pp, string exectLocation) { var loginUserId = User.Identity.GetUserId(); if (loginUserId == null) { return(BadRequest()); } Ad ad = new Ad(); ad.title = title; ElectronicsController e = new ElectronicsController(); // e.MyAd(ad, "Save", "Services"); ad.category = "Services"; ad.status = "a"; ad.type = true; ad.condition = "z"; ad.description = " "; ad.postedBy = loginUserId; ad.time = DateTime.UtcNow; db.Ads.Add(ad); try { await db.SaveChangesAsync(); } catch (Exception ed) { string s = ed.ToString(); } e.SaveTags(tags, ad); e.MyAdLocation(city, pp, exectLocation, ad, "Save"); await db.SaveChangesAsync(); return(Ok("Done")); }
public async Task <object> ExternalLoginCallback(string returnUrl) { var loginInfo = await AuthenticationManager.GetExternalLoginInfoAsync(); if (loginInfo == null) { return(RedirectToAction("Login")); } string pictureUrl = null; string gender = "Male"; bool verified = false; string name = null; DateTime?dateOfBirth = null; string city = null; if (loginInfo.Login.LoginProvider == "Facebook") { ClaimsIdentity ext = await AuthenticationManager.GetExternalIdentityAsync(DefaultAuthenticationTypes.ExternalCookie); var access_token = ext.Claims.First(x => x.Type.Equals("urn:facebook:access_token")).Value; var fb = new FacebookClient(access_token); dynamic myInfo = fb.Get("/me?fields=name,email,gender,verified,birthday,location"); // specify the email field loginInfo.Email = myInfo.email; pictureUrl = GetPictureUrl(myInfo.id); loginInfo.DefaultUserName = loginInfo.Email; verified = myInfo.verified; gender = myInfo.gender; dateOfBirth = myInfo.birthday; city = myInfo.location; name = myInfo.name; loginInfo.Email = name; } var user = await UserManager.FindAsync(loginInfo.Login); if (user != null) //User already exists. just update dp { await SignInAsync(user, isPersistent : true); if (pictureUrl != null && pictureUrl != "") { WebClient wc = new WebClient(); byte[] bytes = wc.DownloadData(pictureUrl); MemoryStream ms = new MemoryStream(bytes); System.Drawing.Image img = System.Drawing.Image.FromStream(ms); string fileName = @"\Images\Users\p" + DateTime.UtcNow.Ticks + ".jpg"; img.Save(Server.MapPath(fileName)); ElectronicsController.UploadDPToAWS(Server.MapPath(fileName), "p" + user.Id + ".jpg"); if (System.IO.File.Exists(Server.MapPath(fileName))) { System.IO.File.Delete(Server.MapPath(fileName)); } } return(RedirectToLocal(returnUrl)); } else { if (loginInfo.DefaultUserName != null) //new user with an email address { var newUser = new ApplicationUser() { UserName = loginInfo.DefaultUserName }; var result = await UserManager.CreateAsync(newUser); if (result.Succeeded) { result = await UserManager.AddLoginAsync(newUser.Id, loginInfo.Login); if (result.Succeeded) { await SignInAsync(newUser, isPersistent : true); if (pictureUrl != null && pictureUrl != "") { WebClient wc = new WebClient(); byte[] bytes = wc.DownloadData(pictureUrl); MemoryStream ms = new MemoryStream(bytes); System.Drawing.Image img = System.Drawing.Image.FromStream(ms); string fileName = @"\Images\Users\p" + DateTime.UtcNow.Ticks + ".jpg"; img.Save(Server.MapPath(fileName)); ElectronicsController.UploadDPToAWS(Server.MapPath(fileName), "p" + newUser.Id + ".jpg"); if (System.IO.File.Exists(Server.MapPath(fileName))) { System.IO.File.Delete(Server.MapPath(fileName)); } } string id = newUser.Id; AspNetUser aspNetUser = await db.AspNetUsers.FindAsync(id); aspNetUser.Email = name; aspNetUser.EmailConfirmed = verified; aspNetUser.hideDateOfBirth = true; aspNetUser.hideEmail = true; aspNetUser.hidePhoneNumber = true; aspNetUser.hideFriends = true; aspNetUser.gender = gender; aspNetUser.city = city; aspNetUser.dateOfBirth = dateOfBirth; aspNetUser.dpExtension = ".jpg"; aspNetUser.since = DateTime.UtcNow; aspNetUser.status = "active"; db.Entry(aspNetUser).State = System.Data.Entity.EntityState.Modified; await db.SaveChangesAsync(); await SendMailtoConfirmEmailAddress(aspNetUser.Id, aspNetUser.Email, aspNetUser.UserName); return(RedirectToLocal(returnUrl)); } } TempData["LError"] = "An account already exists by this email address.Try to login"; ViewBag.ReturnUrl = returnUrl; ViewBag.email = loginInfo.DefaultUserName; return(View("Login")); // return "An account already exists by this email address"; //go to login page and TempData["LError"] } ViewBag.pictureUrl = pictureUrl; ViewBag.name = name; ViewBag.dateOfBirth = dateOfBirth; ViewBag.city = city; ViewBag.gender = gender; ViewBag.Login = loginInfo.Login; return(RedirectToAction("ExternalLoginInfo", new { returnUrl = returnUrl })); return("Error"); //GetExternalProperties(); //remove // If the user does not have an account, then prompt the user to create an account //ViewBag.ReturnUrl = returnUrl; //ViewBag.LoginProvider = loginInfo.Login.LoginProvider; //return View("ExternalLoginConfirmation", new ExternalLoginConfirmationViewModel { UserName = loginInfo.DefaultUserName }); } }
public async Task <IHttpActionResult> SendEmail() { ElectronicsController.sendEmail("*****@*****.**", "just for test review", "hi are you there"); return(Ok("Done")); }
public ActionResult Create([Bind(Include = "Id,title,shortabout,longabout,since,contactNo1,contactNo2,email,fblink,twlink,websitelink,owner,logoextension,category,createdBy,time,status,cityId,popularPlaceId,exectLocation")] Company company) { if (ModelState.IsValid) { if (Request.IsAuthenticated) { company.createdBy = User.Identity.GetUserId(); company.time = DateTime.UtcNow; company.status = "a"; db.Companies.Add(company); SaveTags(company); try { db.SaveChanges(); } catch (DbEntityValidationException e) { string s = e.ToString(); List <string> errorMessages = new List <string>(); foreach (DbEntityValidationResult validationResult in e.EntityValidationErrors) { string entityName = validationResult.Entry.Entity.GetType().Name; foreach (DbValidationError error in validationResult.ValidationErrors) { errorMessages.Add(entityName + "." + error.PropertyName + ": " + error.ErrorMessage); } } } catch (Exception e) { string ss = e.ToString(); } return(RedirectToAction("Details", "Company", new { id = company.Id, title = ElectronicsController.URLFriendly(company.title) })); } } return(View(company)); }
public ActionResult UpdateMobileAccessoriesAd([Bind(Include = "Id,category,postedBy,title,description,time")] Ad ad) { if (ModelState.IsValid) { if (Request.IsAuthenticated) { if (Request["postedBy"] == User.Identity.GetUserId()) { FileName[] fileNames = JsonConvert.DeserializeObject <FileName[]>(Request["files"]); MobileAd mobileAd = new MobileAd(); mobileAd.sims = Request["sims"]; mobileAd.color = Request["color"]; IdStatus idstatus = SaveMobileBrandModel(); mobileAd.mobileId = idstatus.id; ad.status = idstatus.status; ad = electronicController.MyAd(ad, "Update"); //tags electronicController.SaveTags(Request["tags"], ad, "update"); //location electronicController.PostAdByCompanyPage(ad.Id, true); electronicController.MyAdLocation(Request["city"], Request["popularPlace"], Request["exectLocation"], ad, "Update"); electronicController.ReplaceAdImages(ad, fileNames); //db.Ads.Add(ad); mobileAd.Id = ad.Id; db.Entry(mobileAd).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Details", "Electronics", new { id = ad.Id, title = ElectronicsController.URLFriendly(ad.title) })); } } return(RedirectToAction("Register", "Account")); } return(View("EditAd", ad)); }
public void Execute(IJobExecutionContext context) { ElectronicsController.sendEmail("*****@*****.**", "I am job scheduler v 2.0 ", ".I am running at " + DateTime.UtcNow); }
public async Task <bool> SaveLocation(string city, string popularPlace) { if (city != null && city != "undefined") { var citydb = db.Cities.FirstOrDefault(x => x.cityName.Equals(city, StringComparison.OrdinalIgnoreCase)); if (citydb == null) { City cit = new City(); cit.cityName = city; cit.addedBy = System.Web.HttpContext.Current.User.Identity.GetUserId(); cit.addedBy = System.Web.HttpContext.Current.User.Identity.GetUserId(); cit.addedOn = DateTime.UtcNow; cit.status = "a"; db.Cities.Add(cit); await db.SaveChangesAsync(); if (popularPlace != null && popularPlace != "undefined") { popularPlace pop = new popularPlace(); pop.status = "p"; try { ElectronicsController.Coordinates co = ElectronicsController.GetLongitudeAndLatitude(popularPlace, city); if (co.status) { pop.longitude = co.longitude; pop.latitude = co.latitude; pop.status = "a"; } } catch (Exception e) { } pop.cityId = cit.Id; pop.name = popularPlace; pop.addedBy = System.Web.HttpContext.Current.User.Identity.GetUserId(); pop.addedOn = DateTime.UtcNow; db.popularPlaces.Add(pop); await db.SaveChangesAsync(); } } else { if (popularPlace != null && popularPlace != "undefined") { var ppp = db.popularPlaces.FirstOrDefault(x => x.City.cityName.Equals(city, StringComparison.OrdinalIgnoreCase) && x.name.Equals(popularPlace, StringComparison.OrdinalIgnoreCase)); if (ppp == null) { popularPlace pop = new popularPlace(); pop.status = "p"; try { ElectronicsController.Coordinates co = ElectronicsController.GetLongitudeAndLatitude(popularPlace, city); if (co.status) { pop.longitude = co.longitude; pop.latitude = co.latitude; pop.status = "a"; } } catch (Exception e) { } pop.cityId = citydb.Id; pop.name = popularPlace; pop.addedBy = System.Web.HttpContext.Current.User.Identity.GetUserId(); pop.addedOn = DateTime.UtcNow; db.popularPlaces.Add(pop); await db.SaveChangesAsync(); } } } } return(true); }
public ActionResult Create([Bind(Include = "Id,category,postedBy,time,title,description")] Question question) { if (User.Identity.IsAuthenticated) { if (ModelState.IsValid) { question.time = DateTime.UtcNow; question.postedBy = User.Identity.GetUserId(); db.Questions.Add(question); string s = Request["tags"]; s = s.Trim(); string[] values = s.Split(','); Tag [] tags = new Tag[values.Length]; QuestionTag [] qt = new QuestionTag[values.Length]; //int count = 0; for (int i = 0; i < values.Length; i++) { values[i] = values[i].Trim(); string ss = values[i]; if (ss != "") { var data = db.Tags.FirstOrDefault(x => x.name.Equals(ss, StringComparison.OrdinalIgnoreCase)); tags[i] = new Tag(); if (data != null) { tags[i].Id = data.Id; } else { tags[i].name = values[i]; tags[i].time = DateTime.UtcNow; tags[i].createdBy = User.Identity.GetUserId(); db.Tags.Add(tags[i]); } } else { tags[i] = null; } } db.SaveChanges(); for (int i = 0; i < values.Length; i++) { qt[i] = new QuestionTag(); qt[i].questionId = question.Id; qt[i].tagId = tags[i].Id; db.QuestionTags.Add(qt[i]); } db.SaveChanges(); return(RedirectToAction("Details", new { id = question.Id, title = ElectronicsController.URLFriendly(question.title) })); } ViewBag.postedBy = new SelectList(db.AspNetUsers, "Id", "Email", question.postedBy); return(View(question)); } return(View(question)); }
public async Task <ActionResult> Edit([Bind(Include = "Id,category,postedBy,title,description,time,price,isnegotiable")] Ad ad) { if (ModelState.IsValid) { if (Request.IsAuthenticated) { var ab = Request["postedBy"]; var iddd = User.Identity.GetUserId(); if (Request["postedBy"] == User.Identity.GetUserId()) { await SaveAd(ad, true); electronicController.SaveTags(Request["tags"], ad, "update"); await SaveSkills(Request["skills"], ad, true); //asp.Ads.Add(ad); db.Entry(ad).State = EntityState.Modified; db.SaveChanges(); electronicController.PostAdByCompanyPage(ad.Id, true); //ad.MobileAds.Add(mobileAd); try { db.SaveChanges(); } catch (Exception e) { string sss = e.ToString(); } //location electronicController.MyAdLocation(Request["city"], Request["popularPlace"], Request["exectLocation"], ad, "Update"); return(RedirectToAction("Details", "Electronics", new { id = ad.Id, title = ElectronicsController.URLFriendly(ad.title) })); } } // return View("Edit", ad); } return(RedirectToAction("Details", "Electronics", new { id = ad.Id, title = ElectronicsController.URLFriendly(ad.title) })); }
// GET: /Jobs/Edit/5 public async Task <ActionResult> Edit(int?id) { if (Request.IsAuthenticated) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Ad ad = await db.Ads.FindAsync(id); if (ad == null) { return(HttpNotFound()); } return(View(ad)); } Ad ad1 = await db.Ads.FindAsync(id); return(RedirectToAction("Details", "Electronics", new { id = ad1.Id, title = ElectronicsController.URLFriendly(ad1.title) })); }
public async Task <ActionResult> CallBackFromLockScreen(string email, string ReturnUrl) //if user login using facebook and fb api does not return email { var LoginString = Request["Login"]; var name = Request["name"]; var city = Request["city"]; var gender = Request["gender"]; var dateOfBirth1 = Request["dateOfBirth"]; var pictureUrl = Request["pictureUrl"]; System.DateTime dateofBirth = (System.DateTime)Convert.ChangeType(dateOfBirth1, typeof(System.DateTime)); Microsoft.AspNet.Identity.UserLoginInfo Login = (Microsoft.AspNet.Identity.UserLoginInfo)Convert.ChangeType(LoginString, typeof(Microsoft.AspNet.Identity.UserLoginInfo)); bool isOldUser = db.AspNetUsers.Any(x => x.UserName.Equals(email)); if (isOldUser) { TempData["errorMsg"] = "This Email is already in use."; ViewBag.ReturnUrl = ReturnUrl; return(View("LockScreen")); } var newUser1 = new ApplicationUser() { Email = name, UserName = email }; var result1 = await UserManager.CreateAsync(newUser1); if (result1.Succeeded) { result1 = await UserManager.AddLoginAsync(newUser1.Id, Login); if (result1.Succeeded) { await SignInAsync(newUser1, isPersistent : true); if (pictureUrl != null && pictureUrl != "") { WebClient wc = new WebClient(); byte[] bytes = wc.DownloadData(pictureUrl); MemoryStream ms = new MemoryStream(bytes); System.Drawing.Image img = System.Drawing.Image.FromStream(ms); string fileName = @"\Images\Users\p" + DateTime.UtcNow.Ticks + ".jpg"; img.Save(Server.MapPath(fileName)); ElectronicsController.UploadDPToAWS(Server.MapPath(fileName), "p" + newUser1.Id + ".jpg"); if (System.IO.File.Exists(Server.MapPath(fileName))) { System.IO.File.Delete(Server.MapPath(fileName)); } } string id = newUser1.Id; AspNetUser aspNetUser = await db.AspNetUsers.FindAsync(id); aspNetUser.Email = name; aspNetUser.EmailConfirmed = false; aspNetUser.hideDateOfBirth = true; aspNetUser.hideEmail = true; aspNetUser.hidePhoneNumber = true; aspNetUser.hideFriends = true; aspNetUser.gender = gender; aspNetUser.city = city; aspNetUser.dateOfBirth = dateofBirth; aspNetUser.dpExtension = ".jpg"; aspNetUser.since = DateTime.UtcNow; aspNetUser.status = "active"; db.Entry(aspNetUser).State = System.Data.Entity.EntityState.Modified; await db.SaveChangesAsync(); await SendMailtoConfirmEmailAddress(aspNetUser.Id, aspNetUser.Email, aspNetUser.UserName); return(RedirectToLocal(ReturnUrl)); // return RedirectToAction("ExternalLoginInfo", new { returnUrl = ReturnUrl }); } } //var userId = User.Identity.GetUserId(); //var user = UserManager.FindById(userId); //user.UserName = email; //var updateResult = await UserManager.UpdateAsync(user); //if (updateResult.Succeeded) //{ // await SendMailtoConfirmEmailAddress(user.Id, user.Email, user.UserName); // return RedirectToLocal(ReturnUrl); //} TempData["errorMsg"] = "Some error hs occured. Please enter your email again and continue."; ViewBag.ReturnUrl = ReturnUrl; return(View("LockScreen")); }
public async Task <ActionResult> Create([Bind(Include = "Id,category,postedBy,title,description,time,price,isnegotiable")] Ad ad) { if (Request.IsAuthenticated) { if (ModelState.IsValid) { await SaveAd(ad); electronicController.SaveTags(Request["tags"], ad); await SaveSkills(Request["skills"], ad); electronicController.PostAdByCompanyPage(ad.Id); electronicController.MyAdLocation(Request["city"], Request["popularPlace"], Request["exectLocation"], ad, "Save"); await db.SaveChangesAsync(); return(RedirectToAction("Details", "Electronics", new { id = ad.Id, title = ElectronicsController.URLFriendly(ad.title) })); } } return(View(ad)); }
public ActionResult Update([Bind(Include = "Id,category,subcategory,postedBy,title,description,time")] Ad ad) { if (ModelState.IsValid) { if (Request.IsAuthenticated) { var ab = Request["postedBy"]; var iddd = User.Identity.GetUserId(); if (Request["postedBy"] == User.Identity.GetUserId()) { FileName[] fileNames = JsonConvert.DeserializeObject <FileName[]>(Request["files"]); MobileAd mobileAd = new MobileAd(); mobileAd.sims = Request["sims"]; mobileAd.color = Request["color"]; IdStatus idstatus = SaveMobileBrandModel(); mobileAd.mobileId = idstatus.id; ad.status = idstatus.status; ad = electronicController.MyAd(ad, "Update"); //tags electronicController.SaveTags(Request["tags"], ad, "update"); string brand = Request["brand"]; string model = Request["model"]; var mobileModel = db.MobileModels.FirstOrDefault(x => x.Mobile.brand == brand && x.model == model); mobileAd.mobileId = mobileModel.Id; electronicController.PostAdByCompanyPage(ad.Id, true); mobileAd.Id = ad.Id; //check if mobilead is not saved. var mobdata = db.MobileAds.Any(x => x.Ad.Id.Equals(ad.Id)); if (mobdata) { db.Entry(mobileAd).State = EntityState.Modified; } else { db.MobileAds.Add(mobileAd); } //ad.MobileAds.Add(mobileAd); try { db.SaveChanges(); } catch (Exception e) { string sss = e.ToString(); } //location electronicController.MyAdLocation(Request["city"], Request["popularPlace"], Request["exectLocation"], ad, "Update"); electronicController.ReplaceAdImages(ad, fileNames); return(RedirectToAction("Details", "Electronics", new { id = ad.Id, title = ElectronicsController.URLFriendly(ad.title) })); } } return(RedirectToAction("Register", "Account")); } return(View("Edit", ad)); }
public async Task <ActionResult> Edit([Bind(Include = "Id,category,subcategory,status,postedBy,title,description,time,price,isnegotiable")] Ad ad) { if (ModelState.IsValid) { if (Request.IsAuthenticated) { var ab = Request["postedBy"]; var iddd = User.Identity.GetUserId(); if (Request["postedBy"] == User.Identity.GetUserId()) { FileName[] fileNames = JsonConvert.DeserializeObject <FileName[]>(Request["files"]); ad = electronicController.MyAd(ad, "Update"); electronicController.PostAdByCompanyPage(ad.Id, true); db.SaveChanges(); await SaveRealEstateAd(ad.Id, true); electronicController.SaveTags(Request["tags"], ad, "update"); try { db.SaveChanges(); } catch (Exception e) { string sss = e.ToString(); } //location electronicController.ReplaceAdImages(ad, fileNames); electronicController.MyAdLocation(Request["city"], Request["popularPlace"], Request["exectLocation"], ad, "Update"); return(RedirectToAction("Details", "Electronics", new { id = ad.Id, title = ElectronicsController.URLFriendly(ad.title) })); } } return(RedirectToAction("Register", "Account")); } return(View("Edit", ad)); }
public ActionResult Create([Bind(Include = "Id,category,subcategory,postedBy,title,description,time")] Ad ad) { if (ModelState.IsValid) { if (Request.IsAuthenticated) { //string tempId = Request["tempId"]; FileName[] fileNames = JsonConvert.DeserializeObject <FileName[]>(Request["files"]); MobileAd mobileAd = new MobileAd(); mobileAd.sims = Request["sims"]; mobileAd.color = Request["color"]; IdStatus idstatus = SaveMobileBrandModel(); mobileAd.mobileId = idstatus.id; ad.status = idstatus.status; ad = electronicController.MyAd(ad, "Save", "Mobiles"); electronicController.PostAdByCompanyPage(ad.Id); //images try { db.SaveChanges(); } catch (Exception e) { string sbs = e.ToString(); } //tags electronicController.SaveTags(Request["tags"], ad); // FileUploadHandler(ad); mobileAd.Id = ad.Id; db.MobileAds.Add(mobileAd); //ad.MobileAd.a(mobileAd); try { db.SaveChanges(); } catch (Exception e) { string sbs = e.ToString(); } // ReplaceAdImages(ad.Id,tempId,fileNames); electronicController.ReplaceAdImages(ad, fileNames); //location electronicController.MyAdLocation(Request["city"], Request["popularPlace"], Request["exectLocation"], ad, "Save"); return(RedirectToAction("Details", "Electronics", new { id = ad.Id, title = ElectronicsController.URLFriendly(ad.title) })); } return(RedirectToAction("Register", "Account")); } return(View("Create", ad)); //ViewBag.postedBy = new SelectList(db.AspNetUsers, "Id", "Email", ad.postedBy); //return View(ad); }