public ActionResult MakePayment(Payments payments) { ViewBag.NavigatedTO = "Payment"; var property = _context.Properties.Where(m => m.Id == payments.PropertyId).FirstOrDefault(); var userId = this.User.FindFirstValue(ClaimTypes.NameIdentifier); payments.LandLordId = property.UserId; payments.TenantId = userId; try { var iscorrectformat = false; string uniqueName = null; string filePath = null; FileInfo fi = new FileInfo(payments.UploadedFile.FileName); var actualextension = fi.Extension; var imageextensions = FileFormat.GetSupportedImageTypeExtensionsList(); foreach (var imageExtension in imageextensions) { if (imageExtension == actualextension) { iscorrectformat = true; } } if (iscorrectformat == false) { return(View(payments)); } if (payments.UploadedFile != null) { string uploadsFolder = Path.Combine(_env.WebRootPath, "Images"); uniqueName = Guid.NewGuid().ToString() + "_" + payments.UploadedFile.FileName; filePath = Path.Combine(uploadsFolder, uniqueName); payments.UploadedFile.CopyTo(new FileStream(filePath, FileMode.Create)); payments.ImageName = uniqueName; } } catch { } payments.PaidOn = DateTime.UtcNow; if (property.PropertyModeId == 1) { payments.ExpiryDate = payments.PaidOn.AddMonths(1); } else { payments.ExpiryDate = DateTime.UtcNow.AddYears(70); } Guid g; payments.RecieptNumber = Guid.NewGuid().ToString(); _context.Payments.Add(payments); _context.SaveChanges(); return(RedirectToAction("Index")); }
public async Task <IActionResult> Create([Bind("Id,Name,Address,GoogleMapAddress,ImageName,Price,Description,Area,BedRooms,bathrooms,Garage,Stairs,BuildingConditon,FloorPlanImage,isDealClosed,isDisplayed,Country,CurrencyId,PropertyTypeId,PropertyModeId,UserId,VideoLink,ClosedToId,UploadedFile")] Property @property) { ViewBag.NavigatedTO = "Property"; if (!User.IsInRole("Admin")) { var userId = this.User.FindFirstValue(ClaimTypes.NameIdentifier); @property.UserId = userId; @property.isDisplayed = false; @property.ImageName = "not available"; } if (ModelState.IsValid) { try { var iscorrectformat = false; string uniqueName = null; string filePath = null; FileInfo fi = new FileInfo(@property.UploadedFile.FileName); var actualextension = fi.Extension; var imageextensions = FileFormat.GetSupportedImageTypeExtensionsList(); foreach (var imageExtension in imageextensions) { if (imageExtension == actualextension) { iscorrectformat = true; } } if (iscorrectformat == false) { return(View(@property)); } if (@property.UploadedFile != null) { string uploadsFolder = Path.Combine(_env.WebRootPath, "Images"); uniqueName = Guid.NewGuid().ToString() + "_" + @property.UploadedFile.FileName; filePath = Path.Combine(uploadsFolder, uniqueName); @property.UploadedFile.CopyTo(new FileStream(filePath, FileMode.Create)); @property.ImageName = uniqueName; } } catch { } _context.Add(@property); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["ClosedToId"] = new SelectList(_context.Users, "Id", "Id", @property.ClosedToId); ViewData["PropertyModeId"] = new SelectList(_context.propertyModes, "Id", "Name", @property.PropertyModeId); ViewData["PropertyTypeId"] = new SelectList(_context.PropertyTypes, "Id", "Name", @property.PropertyTypeId); ViewData["UserId"] = new SelectList(_context.Users, "Id", "Id", @property.UserId); return(View(@property)); }
public async Task <IActionResult> Create([Bind("Id,Testimony,UserId,isApproved,UploadedFile,ImageName")] Testimonials testimonials) { if (!User.IsInRole("Admin")) { var userId = this.User.FindFirstValue(ClaimTypes.NameIdentifier); testimonials.UserId = userId; testimonials.isApproved = false; testimonials.ImageName = "not available"; } try { try { var iscorrectformat = false; string uniqueName = null; string filePath = null; FileInfo fi = new FileInfo(testimonials.UploadedFile.FileName); var actualextension = fi.Extension; var imageextensions = FileFormat.GetSupportedImageTypeExtensionsList(); foreach (var imageExtension in imageextensions) { if (imageExtension == actualextension) { iscorrectformat = true; } } if (iscorrectformat == false) { return(View(testimonials)); } if (testimonials.UploadedFile != null) { string uploadsFolder = Path.Combine(_env.WebRootPath, "Images"); uniqueName = Guid.NewGuid().ToString() + "_" + testimonials.UploadedFile.FileName; filePath = Path.Combine(uploadsFolder, uniqueName); testimonials.UploadedFile.CopyTo(new FileStream(filePath, FileMode.Create)); testimonials.ImageName = uniqueName; } } catch { return(View(testimonials)); } _context.Add(testimonials); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } catch { } ViewData["UserId"] = new SelectList(_context.Users, "Id", "UserName", testimonials.UserId); return(View(testimonials)); }
public async Task <IActionResult> Create([Bind("Id,ImageName,PropertiesId,UploadedFile")] PropertySlider propertySlider) { ViewBag.NavigatedTO = "Slider"; if (ModelState.IsValid) { try { var iscorrectformat = false; string uniqueName = null; string filePath = null; FileInfo fi = new FileInfo(propertySlider.UploadedFile.FileName); var actualextension = fi.Extension; var imageextensions = FileFormat.GetSupportedImageTypeExtensionsList(); foreach (var imageExtension in imageextensions) { if (imageExtension == actualextension) { iscorrectformat = true; } } if (iscorrectformat == false) { return(View(propertySlider)); } if (propertySlider.UploadedFile != null) { string uploadsFolder = Path.Combine(_env.WebRootPath, "Images"); uniqueName = Guid.NewGuid().ToString() + "_" + propertySlider.UploadedFile.FileName; filePath = Path.Combine(uploadsFolder, uniqueName); propertySlider.UploadedFile.CopyTo(new FileStream(filePath, FileMode.Create)); propertySlider.ImageName = uniqueName; } } catch { } _context.Add(propertySlider); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["PropertiesId"] = new SelectList(_context.Properties, "Id", "Address", propertySlider.PropertiesId); return(View(propertySlider)); }
public async Task <IActionResult> Create(EasyRent.Models.User applicationUser) { ViewBag.NavigatedTO = "Profile"; var user = db.Users.Where(m => m.Id == applicationUser.Id).FirstOrDefault(); user.LastName = applicationUser.LastName; user.FirstName = applicationUser.FirstName; user.MiddleName = applicationUser.MiddleName; user.About = applicationUser.About; user.Address = applicationUser.Address; user.FacebookLink = applicationUser.FacebookLink; user.TwitterLink = applicationUser.TwitterLink; user.MobileNumber = applicationUser.MobileNumber; user.Quote = applicationUser.Quote; user.InstagramLink = applicationUser.InstagramLink; user.LinkedInLink = applicationUser.LinkedInLink; user.Language = applicationUser.Language; user.Skills = applicationUser.Skills; if (String.IsNullOrEmpty(user.Id)) { return(NotFound()); } if (ModelState.IsValid) { try { var iscorrectformat = false; string uniqueName = null; string filePath = null; FileInfo fi = new FileInfo(applicationUser.UploadedFile.FileName); var actualextension = fi.Extension; var imageextensions = FileFormat.GetSupportedImageTypeExtensionsList(); foreach (var imageExtension in imageextensions) { if (imageExtension == actualextension) { iscorrectformat = true; } } if (iscorrectformat == false) { return(View(applicationUser)); } if (applicationUser.UploadedFile != null) { string uploadsFolder = Path.Combine(_env.WebRootPath, "Images"); uniqueName = Guid.NewGuid().ToString() + "_" + applicationUser.UploadedFile.FileName; filePath = Path.Combine(uploadsFolder, uniqueName); applicationUser.UploadedFile.CopyTo(new FileStream(filePath, FileMode.Create)); applicationUser.ImageName = uniqueName; user.ImageName = applicationUser.ImageName; } } catch { } try { db.Update(user); await db.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } catch { } } return(View("Index", applicationUser)); }