public JsonResult SaveAlbum(AlbumModel album) { var sessionId = this.Session["SessionID"].ToString(); IUserSessionRepository userSessionRepository = RepositoryClassFactory.GetInstance().GetUserSessionRepository(); UserSession userSession = userSessionRepository.FindByID(sessionId); if (userSession == null) { return(Json(new { errorCode = (int)ErrorCode.Redirect, message = Resources.AdminResource.msg_sessionInvalid }, JsonRequestBehavior.AllowGet)); } InsertResponse response = new InsertResponse(); album.Title = album.Title.Length > 200 ? album.Title.Substring(0, 100) + "..." : album.Title; if (!string.IsNullOrEmpty(album.Description)) { album.Description = album.Description.Length > 300 ? album.Description.Substring(0, 296) + "..." : album.Description; } else { album.Description = null; } album.ActionURL = string.Format("{0}-{1}", UrlSlugger.ToUrlSlug(album.Title), UrlSlugger.Get8Digits()); album.CreatedDate = DateTime.Now; album.AlbumID = Guid.NewGuid().ToString(); album.CreatedBy = userSession != null ? userSession.UserID : string.Empty; response = _albumService.CreateAlbum(album); return(Json(new { errorCode = response.ErrorCode, message = response.Message }, JsonRequestBehavior.AllowGet)); }
public JsonResult SaveVideo(VideoModel video) { var sessionId = this.Session["SessionID"].ToString(); IUserSessionRepository userSessionRepository = RepositoryClassFactory.GetInstance().GetUserSessionRepository(); UserSession userSession = userSessionRepository.FindByID(sessionId); if (userSession == null) { return(Json(new { errorCode = (int)ErrorCode.Redirect, message = Resources.AdminResource.msg_sessionInvalid }, JsonRequestBehavior.AllowGet)); } InsertResponse response = new InsertResponse(); video.Title = video.Title.Length > 200 ? video.Title.Substring(0, 100) + "..." : video.Title; if (!string.IsNullOrEmpty(video.Shortcontent)) { video.Shortcontent = video.Shortcontent.Length > 300 ? video.Shortcontent.Substring(0, 296) + "..." : video.Shortcontent; } else { video.Shortcontent = null; } video.ActionURL = string.Format("{0}-{1}", UrlSlugger.ToUrlSlug(video.Title), UrlSlugger.Get8Digits()); video.CreatedDate = DateTime.Now; video.VideoID = Guid.NewGuid().ToString(); video.CreatedBy = userSession != null ? userSession.UserID : string.Empty; response = _videoService.CreateVideo(video); return(Json(new { errorCode = response.ErrorCode, message = response.Message }, JsonRequestBehavior.AllowGet)); }
public JsonResult SaveImportantDeadline(ImportantDeadlineModel importantDeadline) { var sessionId = this.Session["SessionID"].ToString(); IUserSessionRepository userSessionRepository = RepositoryClassFactory.GetInstance().GetUserSessionRepository(); UserSession userSession = userSessionRepository.FindByID(sessionId); if (userSession == null) { return(Json(new { errorCode = (int)ErrorCode.Redirect, message = Resources.AdminResource.msg_sessionInvalid }, JsonRequestBehavior.AllowGet)); } InsertResponse response = new InsertResponse(); importantDeadline.Title = importantDeadline.Title.Length > 200 ? importantDeadline.Title.Substring(0, 100) + "..." : importantDeadline.Title; if (importantDeadline.ShortContent != null) { importantDeadline.ShortContent = importantDeadline.ShortContent.Length > 300 ? importantDeadline.ShortContent.Substring(0, 296) + "..." : importantDeadline.ShortContent; } importantDeadline.DeadlineID = Guid.NewGuid().ToString(); importantDeadline.ActionURL = string.Format("{0}-{1}", UrlSlugger.ToUrlSlug(importantDeadline.Title), UrlSlugger.Get8Digits()); importantDeadline.CreatedDate = DateTime.Now; importantDeadline.CreatedBy = userSession != null ? userSession.UserID : string.Empty; response = _importantDeadline.CreateImportantDeadline(importantDeadline); return(Json(new { errorCode = response.ErrorCode, message = response.Message }, JsonRequestBehavior.AllowGet)); }
public override Tag Add(Tag entity, string addedBy) { if (string.IsNullOrEmpty(entity.UrlSlug)) { entity.UrlSlug = UrlSlugger.ToUrlSlug(entity.Name); } return(base.Add(entity, addedBy)); }
public override Task <Result <Form> > CreateAsync(CancellationToken cancellationToken, Form entity, string createdBy) { if (string.IsNullOrEmpty(entity.UrlSlug)) { entity.UrlSlug = UrlSlugger.ToUrlSlug(entity.Name); } return(base.CreateAsync(cancellationToken, entity, createdBy)); }
public override BlogPost Update(BlogPost entity, string updatedBy) { if (string.IsNullOrEmpty(entity.UrlSlug)) { entity.UrlSlug = UrlSlugger.ToUrlSlug(entity.Title); } return(base.Update(entity, updatedBy)); }
public override Task <Result> UpdateAsync(object id, LocationDto dto, string updatedBy, CancellationToken cancellationToken) { if (string.IsNullOrEmpty(dto.UrlSlug)) { dto.UrlSlug = UrlSlugger.ToUrlSlug(dto.Name); } return(base.UpdateAsync(id, dto, updatedBy, cancellationToken)); }
public override Task <Result> UpdateAsync(CancellationToken cancellationToken, Section entity, string updatedBy) { if (string.IsNullOrEmpty(entity.UrlSlug)) { entity.UrlSlug = UrlSlugger.ToUrlSlug(entity.Name); } return(base.UpdateAsync(cancellationToken, entity, updatedBy)); }
public override async Task <Result <Location> > CreateAsync(CancellationToken cancellationToken, Location entity, string createdBy) { if (string.IsNullOrEmpty(entity.UrlSlug)) { entity.UrlSlug = UrlSlugger.ToUrlSlug(entity.Name); } return(await base.CreateAsync(cancellationToken, entity, createdBy).ConfigureAwait(false)); }
public override Task <Result <LocationDto> > CreateAsync(LocationDto dto, string createdBy, CancellationToken cancellationToken) { if (string.IsNullOrEmpty(dto.UrlSlug)) { dto.UrlSlug = UrlSlugger.ToUrlSlug(dto.Name); } return(base.CreateAsync(dto, createdBy, cancellationToken)); }
public async override Task <Result <BlogPost> > CreateAsync(CancellationToken cancellationToken, BlogPost entity, string createdBy) { if (string.IsNullOrEmpty(entity.UrlSlug)) { entity.UrlSlug = UrlSlugger.ToUrlSlug(entity.Title); } return(await base.CreateAsync(cancellationToken, entity, createdBy).ConfigureAwait(false)); }
public override BlogPost Add(BlogPost entity, string addedBy) { if (string.IsNullOrEmpty(entity.UrlSlug)) { entity.UrlSlug = UrlSlugger.ToUrlSlug(entity.Title); } return(base.Add(entity, addedBy)); }
public override async Task <Result> UpdateAsync(CancellationToken cancellationToken, DND.Domain.Blog.Locations.Location entity, string updatedBy) { if (string.IsNullOrEmpty(entity.UrlSlug)) { entity.UrlSlug = UrlSlugger.ToUrlSlug(entity.Name); } return(await base.UpdateAsync(cancellationToken, entity, updatedBy).ConfigureAwait(false)); }
public override Category Update(Category entity, string updatedBy) { if (string.IsNullOrEmpty(entity.UrlSlug)) { entity.UrlSlug = UrlSlugger.ToUrlSlug(entity.Name); } return(base.Update(entity, updatedBy)); }
public JsonResult SaveUpdateConference(ConferenceDeclarationModel conference, HttpPostedFileBase imageFile, HttpPostedFileBase file) { var sessionId = this.Session["SessionID"].ToString(); IUserSessionRepository userSessionRepository = RepositoryClassFactory.GetInstance().GetUserSessionRepository(); UserSession userSession = userSessionRepository.FindByID(sessionId); if (userSession == null) { return(Json(new { errorCode = (int)ErrorCode.Redirect, message = Resources.AdminResource.msg_sessionInvalid }, JsonRequestBehavior.AllowGet)); } //conference.ActionURL = string.Format("{0}-{1}", UrlSlugger.ToUrlSlug(conference.Title), UrlSlugger.Get8Digits()); conference.UpdatedBy = userSession.UserID; conference.UpdatedDate = DateTime.Now; BaseResponse response = _conferenceService.UpdateConference(conference); if (response.ErrorCode == (int)ErrorCode.None) { //Image if (imageFile != null) { //Create Folder try { if (!System.IO.File.Exists(Server.MapPath("~/Content/upload/images/Conference/"))) { Directory.CreateDirectory(Server.MapPath("~/Content/upload/images/Conference/")); } } catch (Exception) { } string extension = imageFile.FileName.Substring(imageFile.FileName.LastIndexOf(".")); string filename = imageFile.FileName.Substring(0, imageFile.FileName.LastIndexOf(".")).Replace(" ", "-"); filename = string.Format("{0}-{1}", filename, UrlSlugger.Get8Digits()); imageFile.SaveAs(Server.MapPath("~/Content/upload/images/Conference/" + filename + extension)); conference.ImageURL = "/Content/upload/images/Conference/" + filename + extension; _conferenceService.UpdateConference(conference); } if (file != null) { //Create Folder try { if (!System.IO.File.Exists(Server.MapPath("~/Content/upload/documents/Conference/"))) { Directory.CreateDirectory(Server.MapPath("~/Content/upload/documents/Conference/")); } } catch (Exception) { } string extension = file.FileName.Substring(file.FileName.LastIndexOf(".")); string filename = file.FileName.Substring(0, file.FileName.LastIndexOf(".")).Replace(" ", "-"); filename = string.Format("{0}-{1}", filename, UrlSlugger.Get8Digits()); file.SaveAs(Server.MapPath("~/Content/upload/documents/Conference/" + filename + extension)); conference.AttachmentURL = "/Content/upload/documents/Conference/" + filename + extension; _conferenceService.UpdateConference(conference); } } return(Json(new { errorCode = response.ErrorCode, message = response.Message }, JsonRequestBehavior.AllowGet)); }
public JsonResult UploadFiles(HttpPostedFileBase file) { var sessionId = this.Session["SessionID"].ToString(); IUserSessionRepository userSessionRepository = RepositoryClassFactory.GetInstance().GetUserSessionRepository(); UserSession userSession = userSessionRepository.FindByID(sessionId); if (userSession == null) { return(Json(new { errorCode = (int)ErrorCode.Redirect, message = Resources.AdminResource.msg_sessionInvalid }, JsonRequestBehavior.AllowGet)); } InsertResponse response = new InsertResponse(); string url = string.Empty; string msg = string.Empty; int errorcode = 0; if (file != null) { try { //Create folder try { if (!System.IO.File.Exists(Server.MapPath("~/Content/upload/files/"))) { Directory.CreateDirectory(Server.MapPath("~/Content/upload/files/")); } } catch (Exception) {} string filename = file.FileName.Substring(0, file.FileName.LastIndexOf(".")); filename = string.Format("{0}-{1}", filename, UrlSlugger.Get8Digits()).Replace(" ", "_"); string extension = file.FileName.Substring(file.FileName.LastIndexOf(".")); file.SaveAs(Server.MapPath("~/Content/upload/files/" + filename + extension)); url = string.Format("{0}://{1}:{2}/{3}", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, "Content/upload/files/" + filename + extension); UploadModel upload = new UploadModel(); upload.UploadID = Guid.NewGuid().ToString(); upload.CreatedBy = userSession.UserID; upload.CreatedDate = DateTime.Now; upload.Title = filename; upload.UploadURL = url; upload.FilePath = "/Content/upload/files/" + filename + extension; response = _uploadService.CreateUpload(upload); } catch (Exception ex) { msg = ex.Message; errorcode = (int)ErrorCode.Error; } } return(Json(new { errorcode = errorcode, message = msg, url = url }, JsonRequestBehavior.AllowGet)); }
public ActionResult UpdateCategoryMenu(MenuModel menu) { if (ModelState.IsValid) { menu.ActionURL = string.Format("{0}-{1}", UrlSlugger.ToUrlSlug(menu.Title), UrlSlugger.Get8Digits()); BaseResponse response = _menuCategoryService.UpdateMenu(menu); ViewBag.Message = response; } return(View("UpdateCategory", menu)); }
public JsonResult SaveUpdateNews(NewsModel news, HttpPostedFileBase imageFile) { var sessionId = this.Session["SessionID"].ToString(); IUserSessionRepository userSessionRepository = RepositoryClassFactory.GetInstance().GetUserSessionRepository(); UserSession userSession = userSessionRepository.FindByID(sessionId); if (userSession == null) { return(Json(new { errorCode = (int)ErrorCode.Redirect, message = Resources.AdminResource.msg_sessionInvalid }, JsonRequestBehavior.AllowGet)); } //news.ActionURL = string.Format("{0}-{1}", UrlSlugger.ToUrlSlug(news.Title), UrlSlugger.Get8Digits()); news.UpdatedBy = userSession.UserID; BaseResponse response = _newsService.UpdateNews(news); if (response.ErrorCode == (int)ErrorCode.None) { //Image if (imageFile != null) { //Create folder try { if (!System.IO.File.Exists(Server.MapPath("~/Content/upload/images/news/"))) { Directory.CreateDirectory(Server.MapPath("~/Content/upload/images/news/")); } } catch (Exception) { } if (!string.IsNullOrEmpty(news.ThumbnailURL)) { if (System.IO.File.Exists(Server.MapPath(news.ThumbnailURL))) { System.IO.File.Delete(Server.MapPath(news.ThumbnailURL)); } } string extension = imageFile.FileName.Substring(imageFile.FileName.LastIndexOf(".")); string filename = imageFile.FileName.Substring(0, imageFile.FileName.LastIndexOf(".")).Replace(" ", "-"); filename = string.Format("{0}-{1}", filename, UrlSlugger.Get8Digits()); imageFile.SaveAs(Server.MapPath("~/Content/upload/images/news/" + filename + extension)); news.ThumbnailURL = "/Content/upload/images/news/" + filename + extension; _newsService.UpdateNews(news); } } return(Json(new { errorCode = response.ErrorCode, message = response.Message }, JsonRequestBehavior.AllowGet)); }
public async Task <Result> UpdateAsync(BlogPost entity, IEnumerable <BlogPostTag> insertTags, IEnumerable <BlogPostTag> deleteTags, IEnumerable <BlogPostLocation> insertLocations, IEnumerable <BlogPostLocation> deleteLocations, string updatedBy, CancellationToken cancellationToken) { if (string.IsNullOrEmpty(entity.UrlSlug)) { entity.UrlSlug = UrlSlugger.ToUrlSlug(entity.Title); } using (var UoW = UnitOfWorkFactory.Create(UnitOfWorkScopeOption.JoinExisting)) { UoW.Repository <ApplicationContext, BlogPost>().UpdateGraph(entity); await UoW.CompleteAsync(cancellationToken).ConfigureAwait(false); } return(Result.Ok()); }
public ActionResult CreateCategoryMenu(MenuModel menu, string parentTitle) { if (ModelState.IsValid) { FindItemReponse <MenuModel> findParentMenu = _menuCategoryService.FindByTitle(parentTitle); if (findParentMenu.Item != null) { menu.ParentID = findParentMenu.Item.MenuID; } menu.MenuID = Guid.NewGuid().ToString(); menu.ActionURL = string.Format("{0}-{1}", UrlSlugger.ToUrlSlug(menu.Title), UrlSlugger.Get8Digits()); menu.CreatedDate = DateTime.Now; InsertResponse response = _menuCategoryService.CreateMenu(menu); } return(RedirectToAction("Index")); }
public JsonResult SaveSlider(SliderModel slider, HttpPostedFileBase imageFile) { var sessionId = this.Session["SessionID"].ToString(); IUserSessionRepository userSessionRepository = RepositoryClassFactory.GetInstance().GetUserSessionRepository(); UserSession userSession = userSessionRepository.FindByID(sessionId); if (userSession == null) { return(Json(new { errorCode = (int)ErrorCode.Redirect, message = Resources.AdminResource.msg_sessionInvalid }, JsonRequestBehavior.AllowGet)); } InsertResponse response = new InsertResponse(); slider.Title = slider.Title.Length > 200 ? slider.Title.Substring(0, 100) + "..." : slider.Title; slider.SliderID = Guid.NewGuid().ToString(); //slider.URL = string.Format("{0}-{1}", UrlSlugger.ToUrlSlug(slider.Title), UrlSlugger.Get8Digits()); slider.CreatedDate = DateTime.Now; slider.CreatedBy = userSession != null ? userSession.UserID : string.Empty; slider.ImageURL = ""; response = _slider.CreateSlider(slider); if (response.ErrorCode == (int)ErrorCode.None) { //Image if (imageFile != null) { //Create folder try { if (!System.IO.File.Exists(Server.MapPath("~/Content/upload/images/slider/"))) { Directory.CreateDirectory(Server.MapPath("~/Content/upload/images/slider/")); } } catch (Exception) { } string extension = imageFile.FileName.Substring(imageFile.FileName.LastIndexOf(".")); string filename = imageFile.FileName.Substring(0, imageFile.FileName.LastIndexOf(".")).Replace(" ", "-"); filename = string.Format("{0}-{1}", filename, UrlSlugger.Get8Digits()); imageFile.SaveAs(Server.MapPath("~/Content/upload/images/slider/" + filename + extension)); slider.ImageURL = "/Content/upload/images/slider/" + filename + extension; _slider.UpdateSlider(slider); } } return(Json(new { errorCode = response.ErrorCode, message = response.Message }, JsonRequestBehavior.AllowGet)); }
public JsonResult SaveUserInfomation(RegistrationModel registration) { if (this.Session["User-SessionID"] == null) { return(Json(new { ErrorCode = (int)ErrorCode.Redirect }, JsonRequestBehavior.AllowGet)); } BaseResponse response = new BaseResponse(); FindItemReponse <UserModel> userResponse = _userService.FindUserByID(registration.UserID); if (userResponse.Item != null) { var user = userResponse.Item; user.Title = registration.Title != "Empty" ? registration.Title : user.Title; user.Email = registration.Email != "Empty" ? registration.Email : user.Email; user.FullName = registration.FullName != "Empty" ? registration.FullName : user.FullName; user.Sex = registration.Sex != "Empty" ? registration.Sex : user.Sex; user.MealPreference = registration.MealPreference != "Empty" ? registration.MealPreference : user.MealPreference; user.DisabilitySpecialTreatment = registration.DisabilityOrTreatment != "Empty" ? registration.DisabilityOrTreatment : user.DisabilitySpecialTreatment; user.OtherEmail = registration.OtherEmail != "Empty" ? registration.OtherEmail : user.OtherEmail; user.PhoneNumber = registration.Phone != "Empty" ? registration.Phone : user.PhoneNumber; user.Address = registration.Address != "Empty" ? registration.Address : user.Address; user.City = registration.City != "Empty" ? registration.City : user.City; user.Country = registration.Country != "Empty" ? registration.Country : user.Country; user.WorkAddress = registration.WorkAddress != "Empty" ? registration.WorkAddress : user.WorkAddress; user.Organization = registration.Organization != "Empty" ? registration.Organization : user.Organization; user.DateOfBirth = registration.DateOfBirth.HasValue ? registration.DateOfBirth : user.DateOfBirth; //Don't update password user.Password = null; //Updare user response = _userService.UpdateUser(user); } else { response.ErrorCode = (int)ErrorCode.Error; response.Message = Resources.Resource.msg_commonError; } FindItemReponse <MailingAddressModel> mailingResponse = _mailingService.FindMailingAddressByID(registration.MailingAddressID); if (mailingResponse.Item != null) { var mailing = mailingResponse.Item; mailing.ParticipantType = registration.ParticipantType != "Empty" ? registration.ParticipantType : mailing.ParticipantType; mailing.ParticipateYouth = registration.YouthConference; mailing.NeedVisaSupport = registration.NeedVisaSupport; mailing.OriginalNationality = registration.OriginalNationality != "Empty" ? registration.OriginalNationality : mailing.OriginalNationality; mailing.CurrentNationality = registration.CurrentNationality != "Empty" ? registration.CurrentNationality : mailing.CurrentNationality; mailing.Occupation = registration.Occupation != "Empty" ? registration.Occupation : mailing.Occupation; mailing.DetailOfEmbassy = registration.DetailOfEmbassy != "Empty" ? registration.DetailOfEmbassy : mailing.DetailOfEmbassy; mailing.PassportNumber = registration.PassportNumber != "Empty" ? registration.PassportNumber : mailing.PassportNumber; mailing.DateOfPassportIssue = registration.DateOfPassportIssue.HasValue ? registration.DateOfPassportIssue.Value : mailing.DateOfPassportIssue; mailing.DateOfPassportExpiry = registration.DateOfPassportExpiry.HasValue ? registration.DateOfPassportExpiry.Value : mailing.DateOfPassportExpiry; //Update mailing response = _mailingService.UpdateMailingAddress(mailing); } else { var mailing = new MailingAddressModel { MailingAddressID = Guid.NewGuid().ToString(), ActivationCode = UrlSlugger.Get8Digits(), CreatedDate = DateTime.Now, ParticipantType = registration.ParticipantType, ParticipateYouth = registration.YouthConference, NeedVisaSupport = registration.NeedVisaSupport, OriginalNationality = registration.OriginalNationality, CurrentNationality = registration.CurrentNationality, Occupation = registration.Occupation, DetailOfEmbassy = registration.DetailOfEmbassy, PassportNumber = registration.PassportNumber, DateOfPassportIssue = registration.DateOfPassportIssue, DateOfPassportExpiry = registration.DateOfPassportExpiry, PassportPhoto1 = registration.PassportPhoto1, PassportPhoto2 = registration.PassportPhoto2, PassportPhoto3 = registration.PassportPhoto3, RegistrationNumber = UrlSlugger.Get8Digits(), TypeOfPassport = registration.TypeOfPassport, UserID = userResponse.Item.UserID }; var insertResponse = _mailingService.CreateMailingAddress(mailing); response.ErrorCode = insertResponse.ErrorCode; response.Message = insertResponse.ErrorCode != (int)ErrorCode.None ? "Please input required fields" : "Update succeeded"; } return(Json(response, JsonRequestBehavior.AllowGet)); }
public JsonResult SavePresentation(PresentationModel presentation, HttpPostedFileBase imageFile, HttpPostedFileBase file) { var sessionId = this.Session["SessionID"].ToString(); IUserSessionRepository userSessionRepository = RepositoryClassFactory.GetInstance().GetUserSessionRepository(); UserSession userSession = userSessionRepository.FindByID(sessionId); if (userSession == null) { return(Json(new { errorCode = (int)ErrorCode.Redirect, message = Resources.AdminResource.msg_sessionInvalid }, JsonRequestBehavior.AllowGet)); } InsertResponse response = new InsertResponse(); presentation.Title = presentation.Title.Length > 200 ? presentation.Title.Substring(0, 100) + "..." : presentation.Title; if (!string.IsNullOrEmpty(presentation.ShortContent)) { presentation.ShortContent = presentation.ShortContent.Length > 300 ? presentation.ShortContent.Substring(0, 296) + "..." : presentation.ShortContent; } else { presentation.ShortContent = null; } presentation.ActionURL = string.Format("{0}-{1}", UrlSlugger.ToUrlSlug(presentation.Title), UrlSlugger.Get8Digits()); presentation.CreatedDate = DateTime.Now; presentation.PresentationID = Guid.NewGuid().ToString(); presentation.CreatedBy = userSession != null ? userSession.UserID : string.Empty; response = _presentationService.CreatePresentation(presentation); if (response.ErrorCode == (int)ErrorCode.None) { //Image if (imageFile != null) { //Create Folder try { if (!System.IO.File.Exists(Server.MapPath("~/Content/upload/images/Presentation/"))) { Directory.CreateDirectory(Server.MapPath("~/Content/upload/images/Presentation/")); } } catch (Exception) { } string extension = imageFile.FileName.Substring(imageFile.FileName.LastIndexOf(".")); string filename = imageFile.FileName.Substring(0, imageFile.FileName.LastIndexOf(".")).Replace(" ", "-"); filename = string.Format("{0}-{1}", filename, UrlSlugger.Get8Digits()); imageFile.SaveAs(Server.MapPath("~/Content/upload/images/Presentation/" + filename + extension)); presentation.ImageURL = "/Content/upload/images/Presentation/" + filename + extension; _presentationService.UpdatePresentation(presentation); } if (file != null) { //Create Folder try { if (!System.IO.File.Exists(Server.MapPath("~/Content/upload/documents/Presentation/"))) { Directory.CreateDirectory(Server.MapPath("~/Content/upload/documents/Presentation/")); } } catch (Exception) { } string extension = file.FileName.Substring(file.FileName.LastIndexOf(".")); string filename = file.FileName.Substring(0, file.FileName.LastIndexOf(".")).Replace(" ", "-"); filename = string.Format("{0}-{1}", filename, UrlSlugger.Get8Digits()); file.SaveAs(Server.MapPath("~/Content/upload/documents/Presentation/" + filename + extension)); presentation.AttachmentURL = "/Content/upload/documents/Presentation/" + filename + extension; _presentationService.UpdatePresentation(presentation); } } return(Json(new { errorCode = response.ErrorCode, message = response.Message }, JsonRequestBehavior.AllowGet)); }
public JsonResult SaveArticle(ArticleModel article, string menuTitle, HttpPostedFileBase file) { var sessionId = this.Session["SessionID"].ToString(); IUserSessionRepository userSessionRepository = RepositoryClassFactory.GetInstance().GetUserSessionRepository(); UserSession userSession = userSessionRepository.FindByID(sessionId); if (userSession == null) { return(Json(new { errorCode = (int)ErrorCode.Redirect, message = Resources.AdminResource.msg_sessionInvalid }, JsonRequestBehavior.AllowGet)); } InsertResponse response = new InsertResponse(); string menuID = null; string url = string.Empty; if (!string.IsNullOrEmpty(menuTitle)) { FindItemReponse <MenuModel> findParentMenu = _menuCategoryService.FindByTitle(menuTitle); if (findParentMenu.Item == null) { return(Json(new { errorCode = (int)ErrorCode.Error, message = string.Format(Resources.AdminResource.msg_menuCategoryNotFound, menuTitle) }, JsonRequestBehavior.AllowGet)); } else { menuID = findParentMenu.Item.MenuID; } } //Create article article.Title = article.Title.Length > 200 ? article.Title.Substring(0, 100) + "..." : article.Title; if (article.ShortContent != null) { article.ShortContent = article.ShortContent.Length > 300 ? article.ShortContent.Substring(0, 296) + "..." : article.ShortContent; } article.ArticleID = Guid.NewGuid().ToString(); article.ActionURL = string.Format("{0}-{1}", UrlSlugger.ToUrlSlug(article.Title), UrlSlugger.Get8Digits()); article.CreatedDate = DateTime.Now; article.CreatedBy = userSession.UserID; article.MenuID = menuID; if (string.IsNullOrEmpty(menuID)) { url = string.Format("{0}://{1}:{2}/Home/ArticleView/{3}", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, article.ActionURL); } response = _articleService.CreateArticle(article); if (response.ErrorCode == (int)ErrorCode.None) { //Image if (file != null) { //Create folder try { if (!System.IO.File.Exists(Server.MapPath("~/Content/upload/images/article/"))) { Directory.CreateDirectory(Server.MapPath("~/Content/upload/images/article/")); } } catch (Exception) { } string extension = file.FileName.Substring(file.FileName.LastIndexOf(".")); string filename = file.FileName.Substring(0, file.FileName.LastIndexOf(".")).Replace(" ", "-"); filename = string.Format("{0}-{1}", filename, UrlSlugger.Get8Digits()); file.SaveAs(Server.MapPath("~/Content/upload/images/article/" + filename + extension)); article.ImageURL = "/Content/upload/images/article/" + filename + extension; _articleService.UpdateArticle(article); } } return(Json(new { errorCode = response.ErrorCode, message = response.Message, url = url }, JsonRequestBehavior.AllowGet)); }
public static string ToUrlSlug(this string s) { return(UrlSlugger.ToUrlSlug(s)); }
public ActionResult Upload(int?chunk, string name, string AlbumID) { FindItemReponse <AlbumModel> albumResponse = _albumService.FindAlbumByID(AlbumID); if (albumResponse.Item == null) { return(Json(new { success = false }, JsonRequestBehavior.AllowGet)); } var sessionId = this.Session["SessionID"].ToString(); IUserSessionRepository userSessionRepository = RepositoryClassFactory.GetInstance().GetUserSessionRepository(); UserSession userSession = userSessionRepository.FindByID(sessionId); if (userSession == null) { return(Json(new { errorCode = (int)ErrorCode.Redirect, message = Resources.AdminResource.msg_sessionInvalid }, JsonRequestBehavior.AllowGet)); } chunk = chunk ?? 0; InsertResponse response = new InsertResponse(); PhotoModel photo = new PhotoModel(); if (chunk == 0) { photo.Title = name.Length > 200 ? name.Substring(0, 100) + "..." : name; photo.ActionURL = string.Format("{0}-{1}", UrlSlugger.ToUrlSlug(photo.Title), UrlSlugger.Get8Digits()); photo.CreatedDate = DateTime.Now; photo.PhotoID = Guid.NewGuid().ToString(); photo.ImageURL = ""; photo.CreatedBy = userSession != null ? userSession.UserID : string.Empty; photo.AlbumID = AlbumID; response = _photoService.CreatePhoto(photo); } if (response.ErrorCode == (int)ErrorCode.None) { var fileUpload = Request.Files[0]; //Image if (fileUpload != null) { //Create Folder try { if (!System.IO.File.Exists(Server.MapPath("~/Content/upload/images/Photo/"))) { Directory.CreateDirectory(Server.MapPath("~/Content/upload/images/Photo/")); } } catch (Exception) { } var uploadPath = Server.MapPath("~/Content/upload/images/Photo/"); string extension = name.Substring(name.LastIndexOf(".")); string filename = name.Substring(0, name.LastIndexOf(".")).Replace(" ", "-"); filename = string.Format("{0}-{1}", filename, UrlSlugger.Get8Digits()); using (var fs = new FileStream(Path.Combine(uploadPath, string.Format("{0}{1}", filename, extension)), chunk == 0 ? FileMode.Create : FileMode.Append)) { var buffer = new byte[fileUpload.InputStream.Length]; fileUpload.InputStream.Read(buffer, 0, buffer.Length); fs.Write(buffer, 0, buffer.Length); } if (chunk == 0) { photo.ImageURL = "/Content/upload/images/Photo/" + filename + extension; _photoService.UpdatePhoto(photo); } } } return(Json(new { success = true }, JsonRequestBehavior.AllowGet)); }
#pragma warning disable 1998 public async override global::System.Threading.Tasks.Task ExecuteAsync() { #line 2 "C:\inetpub\wwwroot\BazarPapelaria10\Views\Shared\Components\ProdutoListagem\Default.cshtml" var pesquisa = Context.Request.Query["pesquisa"]; var ordenacao = Context.Request.Query["ordenacao"].ToString(); #line default #line hidden #line 6 "C:\inetpub\wwwroot\BazarPapelaria10\Views\Shared\Components\ProdutoListagem\Default.cshtml" if (Model.lista.Count > 0) { #line default #line hidden BeginContext(200, 105, true); WriteLiteral(" <div class=\"row\" style=\"margin-top:10px;\">\r\n <div class=\"offset-md-10 col-md-2\">\r\n "); EndContext(); BeginContext(305, 102, false); __tagHelperExecutionContext = __tagHelperScopeManager.Begin("select", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "c8b008da7fc2416e901054759761868d", async() => { } ); __Microsoft_AspNetCore_Mvc_TagHelpers_SelectTagHelper = CreateTagHelper <global::Microsoft.AspNetCore.Mvc.TagHelpers.SelectTagHelper>(); __tagHelperExecutionContext.Add(__Microsoft_AspNetCore_Mvc_TagHelpers_SelectTagHelper); __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_0); #line 11 "C:\inetpub\wwwroot\BazarPapelaria10\Views\Shared\Components\ProdutoListagem\Default.cshtml" __Microsoft_AspNetCore_Mvc_TagHelpers_SelectTagHelper.For = ModelExpressionProvider.CreateModelExpression(ViewData, __model => ordenacao); #line default #line hidden __tagHelperExecutionContext.AddTagHelperAttribute("asp-for", __Microsoft_AspNetCore_Mvc_TagHelpers_SelectTagHelper.For, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_1); #line 11 "C:\inetpub\wwwroot\BazarPapelaria10\Views\Shared\Components\ProdutoListagem\Default.cshtml" __Microsoft_AspNetCore_Mvc_TagHelpers_SelectTagHelper.Items = Model.ordenacao; #line default #line hidden __tagHelperExecutionContext.AddTagHelperAttribute("asp-items", __Microsoft_AspNetCore_Mvc_TagHelpers_SelectTagHelper.Items, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); if (!__tagHelperExecutionContext.Output.IsContentModified) { await __tagHelperExecutionContext.SetOutputContentAsync(); } Write(__tagHelperExecutionContext.Output); __tagHelperExecutionContext = __tagHelperScopeManager.End(); EndContext(); BeginContext(407, 30, true); WriteLiteral("\r\n </div>\r\n </div>\r\n"); EndContext(); BeginContext(439, 47, true); WriteLiteral(" <div class=\"row\" style=\"margin-top:50px\">\r\n"); EndContext(); #line 16 "C:\inetpub\wwwroot\BazarPapelaria10\Views\Shared\Components\ProdutoListagem\Default.cshtml" foreach (var produto in Model.lista) { #line default #line hidden BeginContext(544, 47, true); WriteLiteral(" <div class=\"col-lg-3 col-md-6 mb-4\""); EndContext(); BeginWriteAttribute("value", " value=\"", 591, "\"", 610, 1); #line 18 "C:\inetpub\wwwroot\BazarPapelaria10\Views\Shared\Components\ProdutoListagem\Default.cshtml" WriteAttributeValue("", 599, produto.Id, 599, 11, false); #line default #line hidden EndWriteAttribute(); BeginContext(611, 70, true); WriteLiteral(">\r\n <div class=\"card h-100\">\r\n <a>\r\n"); EndContext(); #line 21 "C:\inetpub\wwwroot\BazarPapelaria10\Views\Shared\Components\ProdutoListagem\Default.cshtml" if (produto.Imagens != null && produto.Imagens.Count() > 0) { #line default #line hidden BeginContext(794, 53, true); WriteLiteral(" <img class=\"card-img-top\""); EndContext(); BeginWriteAttribute("src", " src=\"", 847, "\"", 907, 1); #line 23 "C:\inetpub\wwwroot\BazarPapelaria10\Views\Shared\Components\ProdutoListagem\Default.cshtml" WriteAttributeValue("", 853, Url.Content(produto.Imagens.FirstOrDefault().Caminho), 853, 54, false); #line default #line hidden EndWriteAttribute(); BeginContext(908, 10, true); WriteLiteral(" alt=\"\">\r\n"); EndContext(); #line 24 "C:\inetpub\wwwroot\BazarPapelaria10\Views\Shared\Components\ProdutoListagem\Default.cshtml" } else { #line default #line hidden BeginContext(1002, 28, true); WriteLiteral(" "); EndContext(); BeginContext(1030, 62, false); __tagHelperExecutionContext = __tagHelperScopeManager.Begin("img", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagOnly, "7500667c83a24488b8f83fb1df1470c4", async() => { } ); __Microsoft_AspNetCore_Mvc_Razor_TagHelpers_UrlResolutionTagHelper = CreateTagHelper <global::Microsoft.AspNetCore.Mvc.Razor.TagHelpers.UrlResolutionTagHelper>(); __tagHelperExecutionContext.Add(__Microsoft_AspNetCore_Mvc_Razor_TagHelpers_UrlResolutionTagHelper); __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_2); __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_3); __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_4); await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); if (!__tagHelperExecutionContext.Output.IsContentModified) { await __tagHelperExecutionContext.SetOutputContentAsync(); } Write(__tagHelperExecutionContext.Output); __tagHelperExecutionContext = __tagHelperScopeManager.End(); EndContext(); BeginContext(1092, 2, true); WriteLiteral("\r\n"); EndContext(); #line 28 "C:\inetpub\wwwroot\BazarPapelaria10\Views\Shared\Components\ProdutoListagem\Default.cshtml" } #line default #line hidden BeginContext(1121, 160, true); WriteLiteral(" </a>\r\n <div class=\"card-body\">\r\n <h4 class=\"card-title text-center\">\r\n "); EndContext(); BeginContext(1282, 125, false); #line 32 "C:\inetpub\wwwroot\BazarPapelaria10\Views\Shared\Components\ProdutoListagem\Default.cshtml" Write(Html.ActionLink(produto.ToLower(produto.Nomeprod), "Produto", new { produto, Prod = UrlSlugger.ToUrlSlug(produto.Nomeprod) })); #line default #line hidden EndContext(); BeginContext(1407, 81, true); WriteLiteral("\r\n </h4>\r\n <h5 class=\"text-center\">"); EndContext(); BeginContext(1489, 31, false); #line 34 "C:\inetpub\wwwroot\BazarPapelaria10\Views\Shared\Components\ProdutoListagem\Default.cshtml" Write(produto.Valorprod.ToString("C")); #line default #line hidden EndContext(); BeginContext(1520, 9, true); WriteLiteral("</h5>\r\n\r\n"); EndContext(); #line 36 "C:\inetpub\wwwroot\BazarPapelaria10\Views\Shared\Components\ProdutoListagem\Default.cshtml" if (produto.Descprod != null) { #line default #line hidden BeginContext(1612, 49, true); WriteLiteral(" <p class=\"card-text\">"); EndContext(); BeginContext(1662, 16, false); #line 38 "C:\inetpub\wwwroot\BazarPapelaria10\Views\Shared\Components\ProdutoListagem\Default.cshtml" Write(produto.Descprod); #line default #line hidden EndContext(); BeginContext(1678, 6, true); WriteLiteral("</p>\r\n"); EndContext(); #line 39 "C:\inetpub\wwwroot\BazarPapelaria10\Views\Shared\Components\ProdutoListagem\Default.cshtml" } else { #line default #line hidden BeginContext(1768, 89, true); WriteLiteral(" <p class=\"card-text text-center\">Produto sem descrição.</p>\r\n"); EndContext(); #line 43 "C:\inetpub\wwwroot\BazarPapelaria10\Views\Shared\Components\ProdutoListagem\Default.cshtml" } #line default #line hidden BeginContext(1884, 258, true); WriteLiteral(@" </div> <div class=""card-footer text-center""> <small class=""text-muted"">★ ★ ★ ★ ☆</small> </div> </div> </div> "); EndContext(); #line 50 "C:\inetpub\wwwroot\BazarPapelaria10\Views\Shared\Components\ProdutoListagem\Default.cshtml" } #line default #line hidden BeginContext(2153, 12, true); WriteLiteral(" </div>\r\n"); EndContext(); #line 52 "C:\inetpub\wwwroot\BazarPapelaria10\Views\Shared\Components\ProdutoListagem\Default.cshtml" } #line default #line hidden BeginContext(2168, 113, true); WriteLiteral(" <div style=\"margin-left:auto; margin-right: auto;\">\r\n <div class=\"offset-md-3 col-md-6\">\r\n "); EndContext(); BeginContext(2282, 144, false); #line 55 "C:\inetpub\wwwroot\BazarPapelaria10\Views\Shared\Components\ProdutoListagem\Default.cshtml" Write(Html.PagedListPager((IPagedList)Model.lista, pagina => Url.Action("Index", new { pagina = pagina, pesquisa = pesquisa, ordenacao = ordenacao }))); #line default #line hidden EndContext(); BeginContext(2426, 30, true); WriteLiteral("\r\n </div>\r\n </div>\r\n"); EndContext(); }