public async Task <ActionResult> Create([Bind("Id,CategoryId,Subject,Body,AutherName,ImageUrl")] Post post, IFormFile myfile) { try { if (ModelState.IsValid) { //---------------------------------------------------------------------------------------------------- post.ImageUrl = await UserFile.UploadeNewImageAsync(post.ImageUrl, myfile, _environment.WebRootPath, Properties.Resources.ImgFolder, 100, 100); post.PublicationDate = DateTime.Today.Date; //---------------------------------------------------------------------------------------------------- HttpClient client = newConnection.InitializeClient(); //---------------------------------------------------------------------------------------------------- var content = new StringContent(JsonConvert.SerializeObject(post), Encoding.UTF8, "application/json"); //---------------------------------------------------------------------------------------------------- HttpResponseMessage res = client.PostAsync("api/Posts", content).Result; if (res.IsSuccessStatusCode) { return(RedirectToAction("Index")); } else { throw new Exception(res.ReasonPhrase); } //---------------------------------------------------------------------------------------------------- } return(View(post)); } catch { throw new Exception("Can't complete the process"); } }
public async Task <IActionResult> Edit(int id, [Bind("Id,ApplicationUserId,ActivityType,ArTitle,EnTitle,ArDescription,EnDescription,ActivityDate,ActivityURL,RelationType,Language,CountryId,Photo")] AcademicActivity academicActivity, IFormFile myfile) { if (id != academicActivity.Id) { return(NotFound()); } if (ModelState.IsValid) { try { academicActivity.Photo = await UserFile.UploadeNewImageAsync( _context.AcademicActivities.Where(m => m.Id == id).Select(c => c.Photo).First(), myfile, _environment.WebRootPath, Properties.Resources.ActivityPhotos, 100, 100); _context.Update(academicActivity); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AcademicActivityExists(academicActivity.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["CountryId"] = new SelectList(_context.Countries, "Id", "ArCountryName", academicActivity.CountryId); return(View(academicActivity)); }
public async Task <IActionResult> Edit( int id, [Bind("Id,ArCountryName,EnCountryName,CountryCode,ShortName,Flag")] Country country, IFormFile myfile) { if (id != country.Id) { return(NotFound()); } if (ModelState.IsValid) { try { country.Flag = await UserFile.UploadeNewImageAsync( _context.Countries.Where(m => m.Id == id).Select(c => c.Flag).First(), myfile, _environment.WebRootPath, Properties.Resources.CountryFlagFolder, 100, 100); _context.Update(country); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CountryExists(country.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction("Index")); } return(View(country)); }
public async Task <IActionResult> Create([Bind("Id,Title,MOOCProviderId,Description,SpecialityId,IsFree,IsReported,Language,Certificate,Duration,UniversityId,Link,YouTubeLink,Tags,Instructor,Image,StartDate,ApplicationUserId,DateOfRecord")] MOOCList mOOCList, IFormFile myfile) { if (ModelState.IsValid) { mOOCList.ApplicationUserId = _userManager.GetUserId(User); mOOCList.DateOfRecord = DateTime.Now; mOOCList.Image = await UserFile.UploadeNewImageAsync(mOOCList.Image, myfile, _environment.WebRootPath, Properties.Resources.ScientificEvent, 500, 500); mOOCList.Description = mOOCList.Description.Replace("\n", "<br/>"); mOOCList.Id = Guid.NewGuid(); _context.Add(mOOCList); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["ApplicationUserId"] = new SelectList(_context.ApplicationUsers, "Id", "Id", mOOCList.ApplicationUserId); ViewData["MOOCProviderId"] = new SelectList(_context.MOOCProviders, "Id", "Name", mOOCList.MOOCProviderId); ViewData["SpecialityId"] = new SelectList(_context.Specialities, "Id", "Name", mOOCList.SpecialityId); // ViewData["UniversityId"] = new SelectList(_context.Universities, "Id", "ArUniversityName", mOOCList.UniversityId); return(View(mOOCList)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Email,Description,Website,Fb,Twitter,ApplicationUserId,DateOfRecord,Logo")] MOOCProvider mOOCProvider, IFormFile myfile) { if (id != mOOCProvider.Id) { return(NotFound()); } if (ModelState.IsValid) { try { mOOCProvider.Logo = await UserFile.UploadeNewImageAsync(mOOCProvider.Logo, myfile, _environment.WebRootPath, Properties.Resources.ScientificEvent, 500, 500); _context.Update(mOOCProvider); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MOOCProviderExists(mOOCProvider.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["ApplicationUserId"] = new SelectList(_context.ApplicationUsers, "Id", "Id", mOOCProvider.ApplicationUserId); return(View(mOOCProvider)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Question,CourseChapterId,Indx,IsHidden,Description,Imgurl")] CourseChapterExam courseChapterExam, IFormFile myfile) { if (id != courseChapterExam.Id) { return(NotFound()); } if (ModelState.IsValid) { try { courseChapterExam.Imgurl = await UserFile.UploadeNewImageAsync(courseChapterExam.Imgurl, myfile, _environment.WebRootPath, Properties.Resources.Secured, 500, 500); _context.Update(courseChapterExam); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CourseChapterExamExists(courseChapterExam.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction("Edit", "CourseChapters", new { id = courseChapterExam.CourseChapterId })); } return(View(courseChapterExam)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Indx,CourseId,Logo,Link")] CourseSponsor courseSponsor, IFormFile myfile) { if (id != courseSponsor.Id) { return(NotFound()); } if (ModelState.IsValid) { courseSponsor.Logo = await UserFile.UploadeNewImageAsync(courseSponsor.Logo, myfile, _environment.WebRootPath, Properties.Resources.ScientificEvent, 500, 500); try { _context.Update(courseSponsor); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CourseSponsorExists(courseSponsor.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["CourseId"] = new SelectList(_context.Courses, "Id", "ArName", courseSponsor.CourseId); return(View(courseSponsor)); }
public async Task <IActionResult> Create([Bind("Id,ApplicationUserId,Name,ShortName,BgImage,Logo,Description,CreationDate,CommunityType,SpecialityId,SecurityLevel,IsCommentsAllowed,IsFeatured,IsApproved,IsSuspended,Tags")] Community community, IFormFile myfile, IFormFile myfile1) { if (ModelState.IsValid) { community.ApplicationUserId = _userManager.GetUserId(User); community.BgImage = await UserFile.UploadeNewFileAsync(community.BgImage, myfile, _environment.WebRootPath, Properties.Resources.Community); community.Logo = await UserFile.UploadeNewImageAsync(community.Logo, myfile1, _environment.WebRootPath, Properties.Resources.Community, 50, 50); community.CreationDate = DateTime.Now; community.IsFeatured = false; community.IsSuspended = false; community.IsApproved = false; community.IsCommentsAllowed = true; community.SecurityLevel = SecurityLevel.Open; community.CommunityType = CommunityType.Community; _context.Add(community); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["ApplicationUserId"] = new SelectList(_context.ApplicationUsers, "Id", "Id", community.ApplicationUserId); ViewData["SpecialityId"] = new SelectList(_context.Specialities, "Id", "Name", community.SpecialityId); return(View(community)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,CategoryId,Subject,Body,AuthorName,ImageUrl")] Post post, IFormFile myfile) { if (id != post.Id) { return(NotFound()); } if (ModelState.IsValid) { try { post.ImageUrl = await UserFile.UploadeNewImageAsync(post.ImageUrl, myfile, _environment.WebRootPath, Properties.Resources.ImgFolder, 100, 100); _context.Update(post); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PostExists(post.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["CategoryId"] = new SelectList(_context.Categories, "Id", "Name", post.CategoryId); ViewData["UserId"] = new SelectList(_context.ApplicationUser, "Id", "Id", post.UserId); return(View(post)); }
public async Task <IActionResult> Create([Bind("Id,ArName,EnName,ArDescription,EnDescription,ShortName,Logo,PISSN,EISSN,Email,ActivationDate,CreatedByUserId,EiCId,JournalStatus,Visitors,ReviewerCertificateBackgroundFile,JournalHeader,AuthorCertificateBackgroundFile,PublisherId")] Journal journal, IFormFile myfile, IFormFile myfile1, IFormFile myfile2, IFormFile myfile3) { if (ModelState.IsValid) { journal.Logo = await UserFile.UploadeNewImageAsync(journal.Logo, myfile, _environment.WebRootPath, Properties.Resources.Images, 500, 500); journal.JournalHeader = await UserFile.UploadeNewImageAsync(journal.JournalHeader, myfile1, _environment.WebRootPath, Properties.Resources.Images, 500, 500); journal.ReviewerCertificateBackgroundFile = await UserFile.UploadeNewFileAsync(journal.ReviewerCertificateBackgroundFile, myfile2, _environment.WebRootPath, Properties.Resources.Images); journal.AuthorCertificateBackgroundFile = await UserFile.UploadeNewFileAsync(journal.AuthorCertificateBackgroundFile, myfile3, _environment.WebRootPath, Properties.Resources.Images); journal.CreatedByUserId = _userManager.GetUserId(User); journal.ArDescription = journal.ArDescription.Replace("\n", "<br/>"); journal.EnDescription = journal.EnDescription.Replace("\n", "<br/>"); journal.ActivationDate = DateTime.Now; journal.JournalStatus = JournalStatus.UnderReview; _context.Add(journal); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["ApplicantUserId"] = new SelectList(_context.ApplicationUsers, "Id", "Id", journal.CreatedByUserId); ViewData["EditorinChiefId"] = new SelectList(_context.ApplicationUsers, "Id", "Id", journal.EiCId); ViewData["PublisherId"] = new SelectList(_context.Publishers, "Id", "ArName", journal.PublisherId); return(View(journal)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name,DateOfRecord,StartDate,EndDate,Image,ApplicationUserId,IsActive")] Committee committee, IFormFile myfile) { if (id != committee.Id) { return(NotFound()); } if (ModelState.IsValid) { try { committee.Image = await UserFile.UploadeNewImageAsync(committee.Image, myfile, _environment.WebRootPath, Properties.Resources.ScientificEvent, 500, 500); _context.Update(committee); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CommitteeExists(committee.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["ApplicationUserId"] = new SelectList(_context.ApplicationUsers, "Id", "Id", committee.ApplicationUserId); return(View(committee)); }
public async Task <IActionResult> Create([Bind("Id,Question,CourseChapterId,Indx,IsHidden,Description,Imgurl")] CourseChapterExam courseChapterExam, IFormFile myfile) { if (ModelState.IsValid) { courseChapterExam.Imgurl = await UserFile.UploadeNewImageAsync(courseChapterExam.Imgurl, myfile, _environment.WebRootPath, Properties.Resources.Secured, 500, 500); _context.Add(courseChapterExam); await _context.SaveChangesAsync(); return(RedirectToAction("Edit", "CourseChapters", new { id = courseChapterExam.CourseChapterId })); } return(View(courseChapterExam)); }
public async Task <IActionResult> Create([Bind("Id,Name,Indx,CourseId,Logo,Link")] CourseSponsor courseSponsor, IFormFile myfile) { if (ModelState.IsValid) { courseSponsor.Logo = await UserFile.UploadeNewImageAsync(courseSponsor.Logo, myfile, _environment.WebRootPath, Properties.Resources.ScientificEvent, 500, 500); _context.Add(courseSponsor); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["CourseId"] = new SelectList(_context.Courses, "Id", "ArName", courseSponsor.CourseId); return(View(courseSponsor)); }
public async Task <IActionResult> Create( [Bind("Id,ArCountryName,EnCountryName,CountryCode,ShortName,Flag")] Country country, IFormFile myfile) { if (ModelState.IsValid) { country.Flag = await UserFile.UploadeNewImageAsync(country.Flag, myfile, _environment.WebRootPath, Properties.Resources.CountryFlagFolder, 100, 100); _context.Add(country); await _context.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(country)); }
public async Task <IActionResult> CreateBlog(int?cid, [Bind("Id,Title,Body,DateTime,IsCommentsAllowed,Image,File,IsApproved,IsHidden,IsFeatured,Reads,IsDeleted,CommunityId,ApplicationUserId,Tags,PostType,IsPublishRequest,PublishRequestStatus,IsGifted,GiftType")] Post post, IFormFile myfile, IFormFile myfile1) { if (ModelState.IsValid) { post.Image = await UserFile.UploadeNewImageAsync(post.Image, myfile, _environment.WebRootPath, Properties.Resources.Community, 500, 500); post.File = await UserFile.UploadeNewFileAsync(post.File, myfile1, _environment.WebRootPath, Properties.Resources.Community); post.ApplicationUserId = _userManager.GetUserId(User); post.DateTime = DateTime.Now; post.Reads = 0; post.IsApproved = true; post.IsDeleted = false; post.IsHidden = false; post.IsFeatured = false; post.IsGifted = false; post.Body = (System.Text.RegularExpressions.Regex.Replace(post.Body, @"(?></?\w+)(?>(?:[^>'""]+|'[^']*'|""[^""]*"")*)>", String.Empty)).Replace("\n", "<br/>"); //post.Title = RemoveSpecialChars(post.Title.Replace("/", " ")); // post.Title = post.Title.Replace("/", ""); // post.Title = post.Title.Replace(@"\", string.Empty); //if (_context.Community.SingleOrDefault(a => a.Id == cid).CommunityType == CommunityType.Community) //{ post.PostType = GroupPostType.QA; //} //else //{ post.PostType = PostType.Article; } post.Id = Guid.NewGuid(); _context.Add(post); _context.ScoreLogs.Add(new ScoreLog { Id = Guid.NewGuid(), ApplicationUserId = _userManager.GetUserId(User), PostId = post.Id, Date = DateTime.Now, ScoreValueId = 2 }); await _context.SaveChangesAsync(); return(RedirectToAction("Details", new { id = post.Id })); } ViewData["CommunityId"] = new SelectList(_context.Communities.Where(a => a.Id == post.CommunityId), "Id", "Name", cid); return(View(post)); }
public async Task <IActionResult> Create( [Bind("Id,ArBadgeName,EnBadgeName,ArBadgeDesc,EnBadgeDesc,BadgeLogo,EmailContentId")] Badge badge, IFormFile myfile) { if (ModelState.IsValid) { badge.BadgeLogo = await UserFile.UploadeNewImageAsync(badge.BadgeLogo, myfile, _environment.WebRootPath, Properties.Resources.BadgeLogoFolder, 100, 100); _context.Add(badge); await _context.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewData["EmailContentId"] = new SelectList(_context.EmailContents, "Id", "ArSubject", badge.EmailContentId); return(View(badge)); }
public async Task <IActionResult> Create([Bind("Id,ApplicationUserId,ActivityType,ArTitle,EnTitle,ArDescription,EnDescription,ActivityDate,ActivityURL,RelationType,Language,CountryId,Photo")] AcademicActivity academicActivity, IFormFile myfile) { if (ModelState.IsValid) { academicActivity.Photo = await UserFile.UploadeNewImageAsync(academicActivity.Photo, myfile, _environment.WebRootPath, Properties.Resources.ActivityPhotos, 300, 300); _context.Add(academicActivity); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["ApplicationUserId"] = _userManager.GetUserId(User); ViewData["CountryId"] = new SelectList(_context.Countries, "Id", "ArCountryName", academicActivity.CountryId); return(View(academicActivity)); }
public async Task <IActionResult> Create( [Bind("Id,ArUniversityName,EnUniversityName,Website,StaffNo,StudentNo,LogoHD,LogoThumb,YearofEstablishment,Governmental,SemiPrivate,Private,CountryId,IsIndexed")] University university, IFormFile myfile) { if (ModelState.IsValid) { university.LogoHD = await UserFile.UploadeNewImageAsync(university.LogoHD, myfile, _environment.WebRootPath, Properties.Resources.UniversityLogoFolder, 400, 400); _context.Add(university); await _context.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewData["CountryId"] = new SelectList(_context.Countries, "Id", "ArCountryName", university.CountryId); return(View(university)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,ArName,EnName,ArDescription,EnDescription,ShortName,Logo,PISSN,EISSN,Email,ActivationDate,CreatedByUserId,EiCId,JournalStatus,Visitors,ReviewerCertificateBackgroundFile,JournalHeader,AuthorCertificateBackgroundFile,PublisherId")] Journal journal, IFormFile myfile, IFormFile myfile1, IFormFile myfile2, IFormFile myfile3) { if (id != journal.Id) { return(NotFound()); } if (ModelState.IsValid) { journal.Logo = await UserFile.UploadeNewImageAsync(journal.Logo, myfile, _environment.WebRootPath, Properties.Resources.Images, 500, 500); journal.JournalHeader = await UserFile.UploadeNewImageAsync(journal.JournalHeader, myfile1, _environment.WebRootPath, Properties.Resources.Images, 500, 500); journal.ReviewerCertificateBackgroundFile = await UserFile.UploadeNewFileAsync(journal.ReviewerCertificateBackgroundFile, myfile2, _environment.WebRootPath, Properties.Resources.Images); journal.AuthorCertificateBackgroundFile = await UserFile.UploadeNewFileAsync(journal.AuthorCertificateBackgroundFile, myfile3, _environment.WebRootPath, Properties.Resources.Images); try { _context.Update(journal); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!JournalExists(journal.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["ApplicantUserId"] = new SelectList(_context.ApplicationUsers, "Id", "Id", journal.CreatedByUserId); ViewData["EditorinChiefId"] = new SelectList(_context.ApplicationUsers, "Id", "Id", journal.EiC); ViewData["PublisherId"] = new SelectList(_context.Publishers, "Id", "ArName", journal.PublisherId); return(View(journal)); }
public async Task <IActionResult> Create([Bind("Id,Name,DateOfRecord,StartDate,EndDate,Image,ApplicationUserId,IsActive")] Committee committee, IFormFile myfile) { if (ModelState.IsValid) { committee.ApplicationUserId = _userManager.GetUserId(User); committee.DateOfRecord = DateTime.Now; committee.Image = await UserFile.UploadeNewImageAsync(committee.Image, myfile, _environment.WebRootPath, Properties.Resources.ScientificEvent, 500, 500); _context.Add(committee); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["ApplicationUserId"] = new SelectList(_context.ApplicationUsers, "Id", "Id", committee.ApplicationUserId); return(View(committee)); }
public async Task <IActionResult> Create([Bind("Id,CategoryId,Subject,body,PublicatioDate,AutherName,ImageUrl")] Post post, IFormFile myfile) { if (ModelState.IsValid) { post.ImageUrl = await UserFile.UploadeNewImageAsync(post.ImageUrl, myfile, _environment.WebRootPath, Properties.Resources.ImgFolder, 100, 100); //post.UserId = _userManager.GetUserId(User); _context.Add(post); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["CategoryId"] = new SelectList(_context.Categories, "Id", "Name", post.CategoryId); ViewData["UserId"] = new SelectList(_context.Set <ApplicationUser>(), "Id", "Id", post.UserId); return(View(post)); }
public async Task <IActionResult> Create(int jid, [Bind("Name,Releasedate,Cover,Pdf,Number,JournalId,VolumeId,IsPublished,IsOpen,Visitors,PdfDownloadCounter")] JournalIssue journalIssue, IFormFile myfile, IFormFile myfile1) { if (ModelState.IsValid) { journalIssue.Pdf = await UserFile.UploadeNewFileAsync(journalIssue.Pdf, myfile, _environment.WebRootPath, Properties.Resources.Secured); journalIssue.Cover = await UserFile.UploadeNewImageAsync(journalIssue.Cover, myfile1, _environment.WebRootPath, Properties.Resources.Images, 100, 150); _context.Add(journalIssue); await _context.SaveChangesAsync(); return(RedirectToAction("Index", new { id = jid })); } ViewData["JournalId"] = new SelectList(_context.Journals.Where(a => a.Id == jid), "Id", "ArName", journalIssue.JournalId); ViewData["VolumeId"] = new SelectList(_context.Volumes.Where(a => a.JournalId == jid), "Id", "Id", journalIssue.VolumeId); return(View(journalIssue)); }
public async Task <IActionResult> EditBlog(Guid id, [Bind("Id,Title,Body,DateTime,IsCommentsAllowed,Image,File,IsApproved,IsHidden,IsFeatured,Reads,IsDeleted,CommunityId,ApplicationUserId,Tags,PostType,IsPublishRequest,PublishRequestStatus,IsGifted,GiftType")] Post post, IFormFile myfile, IFormFile myfile1) { if (id != post.Id) { return(NotFound()); } if (ModelState.IsValid) { try { // var postitem = _context.Posts.SingleOrDefault(m => m.Id == id); post.Image = await UserFile.UploadeNewImageAsync(post.Image, myfile, _environment.WebRootPath, Properties.Resources.Community, 500, 500); post.File = await UserFile.UploadeNewFileAsync(post.File, myfile1, _environment.WebRootPath, Properties.Resources.Community); post.ApplicationUserId = _userManager.GetUserId(User); post.DateTime = DateTime.Now; post.IsHidden = post.IsHidden; post.Body = (System.Text.RegularExpressions.Regex.Replace(post.Body, @"(?></?\w+)(?>(?:[^>'""]+|'[^']*'|""[^""]*"")*)>", String.Empty)).Replace("\n", "<br/>"); // post.Title = post.Title.Replace("/", "-"); _context.Update(post); _context.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!PostExists(post.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Details), new { id = post.Id })); } ViewData["ApplicationUserId"] = new SelectList(_context.ApplicationUsers, "Id", "Id", post.ApplicationUserId); ViewData["CommunityId"] = new SelectList(_context.Set <Community>(), "Id", "BgImage", post.CommunityId); return(View(post)); }
public async Task <IActionResult> CreateGroupPost(int?cid, [Bind("Id,Title,Body,DateTime,IsCommentsAllowed,Image,File,IsApproved,IsHidden,IsFeatured,Reads,IsDeleted,CommunityId,ApplicationUserId,Tags,PostType,IsPublishRequest,PublishRequestStatus,IsGifted,GiftType")] Post post, IFormFile myfile, IFormFile myfile1) { if (ModelState.IsValid) { post.Image = await UserFile.UploadeNewImageAsync(post.Image, myfile, _environment.WebRootPath, Properties.Resources.Secured, 700, 500); post.File = await UserFile.UploadeNewFileAsync(post.File, myfile1, _environment.WebRootPath, Properties.Resources.Secured); post.ApplicationUserId = _userManager.GetUserId(User); post.DateTime = DateTime.Now; post.Reads = 0; post.IsApproved = true; post.IsDeleted = false; post.IsHidden = false; post.IsFeatured = false; post.IsGifted = false; //if (_context.Community.SingleOrDefault(a => a.Id == cid).CommunityType == CommunityType.Community) //{ post.PostType = GroupPostType.QA; //} //else //{ post.PostType = PostType.Article; } post.Id = Guid.NewGuid(); _context.Add(post); _context.ScoreLogs.Add(new ScoreLog { Id = Guid.NewGuid(), ApplicationUserId = _userManager.GetUserId(User), PostId = post.Id, Date = DateTime.Now, ScoreValueId = 1 }); await _context.SaveChangesAsync(); return(RedirectToAction("Details", new { id = post.Id })); } ViewData["CommunityId"] = new SelectList(_context.Communities.Where(a => a.Id == post.CommunityId), "Id", "Name", cid); return(View(post)); }
public async Task <IActionResult> Create([Bind("Id,Title,Description,Image,ExternalLink,Controller,Action,Indx,Hits,Date,IsVisible,ApplicationUserId,AdsPositionType,TargetType")] SideAd sideAds, IFormFile myfile) { if (ModelState.IsValid) { sideAds.Image = await UserFile.UploadeNewImageAsync(sideAds.Image, myfile, _environment.WebRootPath, Properties.Resources.Images, 200, 200); sideAds.ApplicationUserId = _userManager.GetUserId(User); sideAds.Hits = 0; sideAds.Date = DateTime.Now; _context.Add(sideAds); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(sideAds)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,ArName,EnName,ApplicationUserId,StartingDate,EndingDate,DateOfRecord,LastUpdate,Image,IntroductoryVideo,Flyer,FilePdf,Effort,IsPaid,CourseFees,Certificate,CertificateCost,IsAdminApproved,IsActive,IsFeatured,Overview,Introduction,LearningOutcomes,Requirements,Tags,SpecialityId,TargetStudents,ImportantDates,Language")] Course course, IFormFile myfile, IFormFile myfile1, IFormFile myfile2) { if (id != course.Id) { return(NotFound()); } if (ModelState.IsValid) { try { course.LastUpdate = DateTime.Now; course.Image = await UserFile.UploadeNewImageAsync(course.Image, myfile, _environment.WebRootPath, Properties.Resources.ScientificEvent, 500, 500); course.Flyer = await UserFile.UploadeNewImageAsync(course.Flyer, myfile1, _environment.WebRootPath, Properties.Resources.ScientificEvent, 500, 500); course.FilePdf = await UserFile.UploadeNewFileAsync(course.FilePdf, myfile2, _environment.WebRootPath, Properties.Resources.ScientificEvent); _context.Update(course); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CourseExists(course.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["ApplicationUserId"] = new SelectList(_context.ApplicationUsers, "Id", "Id", course.ApplicationUserId); ViewData["SpecialityId"] = new SelectList(_context.Specialities, "Id", "EnSpecialityName", course.SpecialityId); return(View(course)); }
public async Task <IActionResult> Create([Bind("Id,Name,Email,Description,Website,Fb,Twitter,ApplicationUserId,DateOfRecord,Logo")] MOOCProvider mOOCProvider, IFormFile myfile) { if (ModelState.IsValid) { mOOCProvider.ApplicationUserId = _userManager.GetUserId(User); mOOCProvider.DateOfRecord = DateTime.Now; mOOCProvider.Logo = await UserFile.UploadeNewImageAsync(mOOCProvider.Logo, myfile, _environment.WebRootPath, Properties.Resources.ScientificEvent, 500, 500); mOOCProvider.Description = mOOCProvider.Description.Replace("\n", "<br/>"); _context.Add(mOOCProvider); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["ApplicationUserId"] = new SelectList(_context.ApplicationUsers, "Id", "Id", mOOCProvider.ApplicationUserId); return(View(mOOCProvider)); }
public async Task <IActionResult> Edit(Guid id, [Bind("Id,ApplicationUserId,Title,Skills,Description,Image,Youtube,Views,RequiredDays,DateOfRecord,PricingType,SkillCategoryType")] FreelancerReadyService freelancerReadyService, IFormFile myfile) { if (id != freelancerReadyService.Id) { return(NotFound()); } if (ModelState.IsValid) { try { freelancerReadyService.Image = await UserFile.UploadeNewImageAsync(freelancerReadyService.Image, myfile, _environment.WebRootPath, Properties.Resources.Images, 500, 500); if (freelancerReadyService.Youtube != null) { int position = freelancerReadyService.Youtube.IndexOf("="); freelancerReadyService.Youtube = freelancerReadyService.Youtube.Substring(position + 1); } _context.Update(freelancerReadyService); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!FreelancerReadyServiceExists(freelancerReadyService.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["ApplicationUserId"] = new SelectList(_context.ApplicationUsers, "Id", "Id", freelancerReadyService.ApplicationUserId); return(View(freelancerReadyService)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,ApplicationUserId,Name,ShortName,BgImage,Logo,Description,CreationDate,CommunityType,SpecialityId,SecurityLevel,IsCommentsAllowed,IsFeatured,IsApproved,IsSuspended,Tags")] Community community, IFormFile myfile, IFormFile myfile1) { if (id != community.Id) { return(NotFound()); } if (ModelState.IsValid) { try { community.BgImage = await UserFile.UploadeNewFileAsync(community.BgImage, myfile, _environment.WebRootPath, Properties.Resources.Community); community.Logo = await UserFile.UploadeNewImageAsync(community.Logo, myfile1, _environment.WebRootPath, Properties.Resources.Community, 50, 50); community.SpecialityId = 1; _context.Update(community); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CommunityExists(community.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["ApplicationUserId"] = new SelectList(_context.ApplicationUsers, "Id", "Id", community.ApplicationUserId); ViewData["SpecialityId"] = new SelectList(_context.Specialities, "Id", "EnSpecialityName", community.SpecialityId); return(View(community)); }
public async Task <IActionResult> Create([Bind("Id,ApplicationUserId,Title,Skills,Description,ExternalLink,Image,File,Likes,Views,DateOfRecord,DateOfAchievement")] FreelancerPortfolio freelancerPortfolio, IFormFile myfile, IFormFile myfile2) { if (ModelState.IsValid) { freelancerPortfolio.Image = await UserFile.UploadeNewImageAsync(freelancerPortfolio.Image, myfile, _environment.WebRootPath, Properties.Resources.Images, 500, 500); freelancerPortfolio.File = await UserFile.UploadeNewFileAsync(freelancerPortfolio.File, myfile2, _environment.WebRootPath, Properties.Resources.Files); freelancerPortfolio.DateOfRecord = DateTime.Now; _context.Add(freelancerPortfolio); await _context.SaveChangesAsync(); //return RedirectToAction(nameof(Index)); return(RedirectToAction("FreelancerDetails", "ApplicationUsers", new { /* routeValues, for example: */ id = freelancerPortfolio.ApplicationUserId })); } ViewData["ApplicationUserId"] = new SelectList(_context.ApplicationUsers, "Id", "Id", freelancerPortfolio.ApplicationUserId); return(View(freelancerPortfolio)); }