// GET: Images/Create public IActionResult Create() { var CreatePageModel = new CreatePageModel(); CreatePageModel.Reviewers = _context.Users.Where(u => u.Id != _userManager.GetUserId(HttpContext.User)).ToList(); return(View(CreatePageModel)); }
public async Task <CreatePageModel> BuildCreatePageModelAsync() { await Task.CompletedTask; var result = new CreatePageModel(); return(result); }
public ActionResult CreatePageMenuForLanguage(int id, string languageId) { var creteModel = new CreatePageModel { Page = new PageModel(), IsTranslate = true }; creteModel.Page.Id = id; return(View("Create", creteModel)); }
public async Task <ActionResult> Create([Bind(Include = "name, group")] CreatePageModel model) { ActionResult result = null; var url = await Pages.CreatePage(model.Name, model.Group); url = url.Replace("/", string.Empty); result = Redirect(string.Format("{0}://{1}:{2}?{3}", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, url)); return(result); }
public ActionResult Create(string AreaName) { var model = new CreatePageModel { Page = new PageModel { AreaName = AreaName }, IsTranslate = false }; return(View(model)); }
public IActionResult Post([FromBody] CreatePageModel model) { var userId = this.GetAuthorizeUserId(); var book = this._bookRepository.GetBookById(model.BookId); if (book == null) { throw new ArgumentNullException("Book was not fount."); } ; var page = TinyMapper.Map <Page>(model); var pageId = this._pageRepository.AddPage(page); return(Created(string.Format("/api/books/{0}/pages/{1}", book.Id, pageId), TinyMapper.Map <PageModel>(page))); }
public ActionResult Create(CreatePageModel model, bool?IsPopup) { if (ModelState.IsValid) { if (model.Page.Id == 0) { model.Page.IsView = HttpContext.Request["IsView"] != null ? true : false; model.Page.IsAdd = HttpContext.Request["IsAdd"] != null ? true : false; model.Page.IsEdit = HttpContext.Request["IsEdit"] != null ? true : false; model.Page.IsDelete = HttpContext.Request["IsDelete"] != null ? true : false; model.Page.IsImport = HttpContext.Request["IsImport"] != null ? true : false; model.Page.IsExport = HttpContext.Request["IsExport"] != null ? true : false; model.Page.IsPrint = HttpContext.Request["IsPrint"] != null ? true : false; var page = new Page(); AutoMapper.Mapper.Map(model.Page, page); page.Name = page.AreaName + "_" + page.ControllerName + "_" + page.ActionName; int pageId = _pageRepository.InsertAndScopIdPage(page); } //Reset cache for pagerightaccess & pagemenu Erp.BackOffice.Helpers.CacheHelper.PagesAccessRight = null; Erp.BackOffice.Helpers.CacheHelper.PagesMenu = null; if (Request["isAjax"] != null) { return(Content("success")); } if (IsPopup == true) { return(RedirectToAction("_ClosePopup", "Home", new { area = "", FunctionCallback = "ClosePopupAndReloadPage" })); } else { TempData[Globals.SuccessMessageKey] = App_GlobalResources.Wording.InsertSuccess; return(RedirectToAction("Index")); } } return(View(model)); }
public async Task <IActionResult> NewScreen(CreatePageModel CreatePageModel, bool newScreen) { if (ModelState.IsValid) { if (newScreen) { CreatePageModel.CommentsAndScreens[0].Screen.ScreenState = Screen.States.Open; var currentUserId = _userManager.GetUserId(HttpContext.User); CreatePageModel.CommentsAndScreens[0].Screen.OwnerId = currentUserId; _context.Screens.Add(CreatePageModel.CommentsAndScreens[0].Screen); var reviewers = _context.Access.Where(r => r.ReviewId == CreatePageModel.CommentsAndScreens[0].Screen.ReviewId).ToList(); foreach (var r in reviewers) { if (!(r.UserId == currentUserId)) { var ScreenStatus = new ScreenStatus(); ScreenStatus.ScreenId = CreatePageModel.CommentsAndScreens[0].Screen.ScreenId; ScreenStatus.UserId = r.UserId; ScreenStatus.Status = ScreenStatus.PossibleStatus.Undecided; _context.Add(ScreenStatus); } } await _context.SaveChangesAsync(); return(Json("true")); } else { var currentUserId = _userManager.GetUserId(HttpContext.User); CreatePageModel.CommentsAndScreens[0].Screen.OwnerId = currentUserId; var parent = _context.Screens.Where(s => s.ScreenId == CreatePageModel.ParentId).FirstOrDefault(); while (parent.ParentId != 0) { parent = _context.Screens.Where(s => s.ScreenId == parent.ParentId).FirstOrDefault(); } CreatePageModel.CommentsAndScreens[0].Screen.ParentId = parent.ScreenId; _context.Screens.Add(CreatePageModel.CommentsAndScreens[0].Screen); var reviewers = _context.Access.Where(r => r.ReviewId == CreatePageModel.CommentsAndScreens[0].Screen.ReviewId).ToList(); foreach (var r in reviewers) { if (!(r.UserId == currentUserId)) { var ScreenStatus = new ScreenStatus(); ScreenStatus.ScreenId = CreatePageModel.CommentsAndScreens[0].Screen.ScreenId; ScreenStatus.UserId = r.UserId; ScreenStatus.Status = ScreenStatus.PossibleStatus.Undecided; _context.Add(ScreenStatus); } } await _context.SaveChangesAsync(); return(Json("true")); } } return(Json("false")); }
public async Task <IActionResult> Create(CreatePageModel CreatePageModel) { if (ModelState.IsValid) { // Review creation var Review = new Review(); //Review.ReviewId = ? Review.CreatorId = _userManager.GetUserId(HttpContext.User); Review.ReviewState = Review.States.Open; Review.ReviewStatus = Review.Status.Undecided; if (CreatePageModel.ReviewTitle != null) { Review.Title = CreatePageModel.ReviewTitle; } else { Review.Title = CreatePageModel.CommentsAndScreens[0].Screen.Title; } Review.Description = CreatePageModel.ReviewDescription; if (CreatePageModel.ReviewThumbnail != null) { Review.Thumbnail = CreatePageModel.ReviewThumbnail; } else { Review.Thumbnail = CreatePageModel.CommentsAndScreens[0].Screen.Content; } _context.Add(Review); if (CreatePageModel.CommentsAndScreens != null) { foreach (var s in CreatePageModel.CommentsAndScreens) { // Screen creation s.Screen.OwnerId = _userManager.GetUserId(HttpContext.User); s.Screen.ScreenState = Screen.States.Open; s.Screen.ReviewId = Review.ReviewId; _context.Add(s.Screen); if (s.CommentList != null) { foreach (var c in s.CommentList) { var comment = new Comment(); comment.ParentId = c.ParentId; comment.Message = c.Message; var userId = _userManager.GetUserId(HttpContext.User); comment.OwnerId = userId; comment.ScreenId = s.Screen.ScreenId; comment.Timestamp = System.DateTime.Now; comment.Lat = c.Lat; comment.Lng = c.Lng; /* if (DataFromBody.CommentUrgency == Urgency.Urgent) * { * comment.CommentUrgency = Models.Comment.Urgency.Urgent; * } * else*/ comment.CommentUrgency = Models.Comment.Urgency.Default; _context.Add(comment); } } } } // Access creation var OwnerEntry = new Access(); OwnerEntry.ReviewId = Review.ReviewId; OwnerEntry.UserId = _userManager.GetUserId(HttpContext.User); _context.Add(OwnerEntry); if (CreatePageModel.Reviewers != null) { foreach (var u in CreatePageModel.Reviewers) { var ReviewerEntry = new Access(); ReviewerEntry.UserId = u.Id; ReviewerEntry.ReviewId = Review.ReviewId; _context.Add(ReviewerEntry); foreach (var s in CreatePageModel.CommentsAndScreens) { var ScreenStatus = new ScreenStatus(); ScreenStatus.ScreenId = s.Screen.ScreenId; ScreenStatus.UserId = u.Id; ScreenStatus.Status = ScreenStatus.PossibleStatus.Undecided; _context.Add(ScreenStatus); } } } await _context.SaveChangesAsync(); return(Json(Url.Action("Index", "Images"))); } return(View(CreatePageModel.CommentsAndScreens)); }
public ActionResult UpdatePage(string id) { var Page = db.cms_page_header.Where(x => x.ID == id).FirstOrDefault(); var Model = new CreatePageModel(); Model.pageHeader = new PagerHeaderDto(); Model.pageHeader.id = id; Model.pageHeader.status = Page.STATUS; Model.pageHeader.type = Page.TYPE; Model.pageHeader.title = Page.TITLE; Model.pageHeader.url = Page.URL; Model.pageHeader.location = ""; ViewBag.Title = "Página " + Model.pageHeader.title; ViewBag.ActiveLeftBarItem = "pages"; FullBreadcrumb.Add("Home|Board/Index"); FullBreadcrumb.Add("Conteúdos|Board/Pages"); FullBreadcrumb.Add("Editar Página|Board/UpdatePage?id=" + id); BuildFastBreadCrumb(FullBreadcrumb, 1); var Modules = db.cms_page_module_mapping.Where(x => x.PAGE_HEADER_ID == id).ToList(); if (Modules.Any()) { Model.modules = new List <ModuleDto>(); foreach (var item in Modules) { if (item.TYPE == "content-module") { var ContentModuleDB = db.cms_page_module_content.Where(x => x.ID == item.MODULE_ID).FirstOrDefault(); var ModuleDto = new ModuleDto(); ModuleDto.type = "content-module"; ModuleDto.title = ContentModuleDB.TITLE; ModuleDto.description = ContentModuleDB.DESCRIPTION; ModuleDto.imageName = ContentModuleDB.IMAGE_NAME; Model.modules.Add(ModuleDto); } else if (item.TYPE == "room-module") { var RoomModuleDB = db.cms_page_module_room.Where(x => x.ID == item.MODULE_ID).FirstOrDefault(); var ModuleDto = new ModuleDto(); ModuleDto.type = "room-module"; ModuleDto.title = RoomModuleDB.TITLE; ModuleDto.description = RoomModuleDB.DESCRIPTION; ModuleDto.imageName = RoomModuleDB.IMAGE_NAME; ModuleDto.higherPrice = RoomModuleDB.HIGHER_PRICE.HasValue ? RoomModuleDB.HIGHER_PRICE.Value.ToString() : ""; ModuleDto.lowerPrice = RoomModuleDB.LOWER_PRICE.HasValue ? RoomModuleDB.LOWER_PRICE.Value.ToString() : ""; var Attributes = db.cms_page_module_room_attributes.Where(x => x.ROOM_ID == RoomModuleDB.ID).ToList(); if (Attributes.Any()) { ModuleDto.attributes = new List <SelectedAttributoDto>(); foreach (var attr in Attributes) { var ThisAttribute = db.attributes.Where(x => x.ID == attr.ATTRIBUTE_ID).FirstOrDefault(); var ThisAttributeValue = db.attributes_values.Where(x => x.ID == attr.ATTRIBUTE_VALUE_ID).FirstOrDefault(); var AttributeDto = new SelectedAttributoDto(); AttributeDto.attributeName = ThisAttribute.NAME; AttributeDto.attributeValueName = ThisAttributeValue.VALUE; ModuleDto.attributes.Add(AttributeDto); } } Model.modules.Add(ModuleDto); } else if (item.TYPE == "gallery-module") { var GalleryModuleDB = db.cms_page_module_gallery.Where(x => x.ID == item.MODULE_ID).FirstOrDefault(); var GalleryItemsDB = db.cms_page_module_gallery_items.Where(x => x.GALLERY_ID == GalleryModuleDB.ID).ToList(); if (GalleryItemsDB.Any()) { var ModuleDto = new ModuleDto(); ModuleDto.type = "gallery-module"; ModuleDto.images = new List <ImageDto>(); foreach (var galleryItem in GalleryItemsDB) { var GalleryItemDto = new ImageDto(); GalleryItemDto.name = galleryItem.IMAGE_NAME; ModuleDto.images.Add(GalleryItemDto); } Model.modules.Add(ModuleDto); } } } } return(View(Model)); }
public ActionResult CreatePage(CreatePageModel model) { var page = new cms_page_header(); page.ID = !string.IsNullOrEmpty(model.pageHeader.id) ? model.pageHeader.id : Guid.NewGuid().ToString(); page.TITLE = model.pageHeader.title; page.STATUS = model.pageHeader.status; page.TYPE = model.pageHeader.type; page.ACTIVE = true; page.CREATION_DATE = DateTime.Now; if (!string.IsNullOrEmpty(model.pageHeader.location)) { var parent = db.cms_page_header.Where(x => x.URL == "/pt" + model.pageHeader.location).FirstOrDefault(); page.PARENT_ID = parent.ID; page.PARENT_PATH = parent.PARENT_PATH + "|" + parent.ID; page.URL = "/pt" + parent.URL + "/" + model.pageHeader.url; } else { page.URL = "/pt" + model.pageHeader.url; } // Check unique URL var uniqueUrl = db.cms_page_header.Where(x => x.URL == page.URL).FirstOrDefault(); if (uniqueUrl != null && string.IsNullOrEmpty(model.pageHeader.id)) { return(Json(new { result = "error-url" }, JsonRequestBehavior.AllowGet)); } db.cms_page_header.Add(page); db.SaveChanges(); var thisPage = db.cms_page_header.OrderByDescending(x => x.IID).FirstOrDefault(); if (model.modules != null && model.modules.Any()) { var counter = 0; foreach (var item in model.modules) { counter++; if (item.type == "content-module") { var contentModule = new cms_page_module_content(); contentModule.TITLE = item.title; contentModule.DESCRIPTION = item.description; if (!string.IsNullOrEmpty(item.image)) { contentModule.IMAGE_NAME = item.imageName; contentModule.IMAGE = Convert.FromBase64String(item.image.Split(',')[1]); contentModule.EXTENSION = "." + item.image.Split('/')[1].Split(';')[0]; } db.cms_page_module_content.Add(contentModule); db.SaveChanges(); var thisContentModuleId = db.cms_page_module_content.OrderByDescending(x => x.ID).FirstOrDefault().ID; var contentModuleMapping = new cms_page_module_mapping(); contentModuleMapping.PAGE_HEADER_ID = thisPage.ID; contentModuleMapping.PAGE_HEADER_IID = thisPage.IID; contentModuleMapping.TYPE = item.type; contentModuleMapping.MODULE_ID = thisContentModuleId; contentModuleMapping.ORDER = counter; db.cms_page_module_mapping.Add(contentModuleMapping); db.SaveChanges(); } else if (item.type == "gallery-module" && item.images != null && item.images.Any()) { var galleryModule = new cms_page_module_gallery(); galleryModule.CREATION_DATE = DateTime.Now; db.cms_page_module_gallery.Add(galleryModule); db.SaveChanges(); var thisGalleryModuleId = db.cms_page_module_gallery.OrderByDescending(x => x.ID).FirstOrDefault().ID; foreach (var image in item.images) { var galleryImage = new cms_page_module_gallery_items(); galleryImage.IMAGE_NAME = image.name; galleryImage.IMAGE = Convert.FromBase64String(image.image.Split(',')[1]); galleryImage.EXTENSON = "." + image.image.Split('/')[1].Split(';')[0]; galleryImage.GALLERY_ID = thisGalleryModuleId; db.cms_page_module_gallery_items.Add(galleryImage); } db.SaveChanges(); var galleryModuleMapping = new cms_page_module_mapping(); galleryModuleMapping.PAGE_HEADER_ID = thisPage.ID; galleryModuleMapping.PAGE_HEADER_IID = thisPage.IID; galleryModuleMapping.TYPE = item.type; galleryModuleMapping.MODULE_ID = thisGalleryModuleId; galleryModuleMapping.ORDER = counter; db.cms_page_module_mapping.Add(galleryModuleMapping); db.SaveChanges(); } else if (item.type == "room-module") { var roomModule = new cms_page_module_room(); roomModule.TITLE = item.title; roomModule.DESCRIPTION = item.description; if (!string.IsNullOrEmpty(item.image)) { roomModule.IMAGE_NAME = item.imageName; roomModule.IMAGE = Convert.FromBase64String(item.image.Split(',')[1]); roomModule.EXTENSION = "." + item.image.Split('/')[1].Split(';')[0]; } if (!string.IsNullOrEmpty(item.higherPrice)) { try { roomModule.HIGHER_PRICE = decimal.Parse(item.higherPrice.Replace('.', ',')); } catch (Exception) { } } if (!string.IsNullOrEmpty(item.lowerPrice)) { try { roomModule.LOWER_PRICE = decimal.Parse(item.lowerPrice.Replace('.', ',')); } catch (Exception) { } } db.cms_page_module_room.Add(roomModule); db.SaveChanges(); var thisRoomModuleId = db.cms_page_module_room.OrderByDescending(x => x.ID).FirstOrDefault().ID; if (item.attributes != null && item.attributes.Any()) { foreach (var attr in item.attributes) { var roomAttribute = new cms_page_module_room_attributes(); roomAttribute.ROOM_ID = thisRoomModuleId; roomAttribute.ATTRIBUTE_ID = attr.id; roomAttribute.ATTRIBUTE_VALUE_ID = attr.valueId; db.cms_page_module_room_attributes.Add(roomAttribute); } db.SaveChanges(); } var roomModuleMapping = new cms_page_module_mapping(); roomModuleMapping.PAGE_HEADER_ID = thisPage.ID; roomModuleMapping.PAGE_HEADER_IID = thisPage.IID; roomModuleMapping.TYPE = item.type; roomModuleMapping.MODULE_ID = thisRoomModuleId; roomModuleMapping.ORDER = counter; db.cms_page_module_mapping.Add(roomModuleMapping); db.SaveChanges(); } } } return(Json(new { result = "ok" }, JsonRequestBehavior.AllowGet)); }