private void RepopulateListsFromCacheSession(ContentVM model) { // Populate cached lists if they are empty. Will invoke service call ContentLookupListsCacheObject CachedLists = cacheManager.ContentListCache; // Retrieve any cached lists to model }
/// <summary> /// Private method to merge in the model /// </summary> /// <returns></returns> private ContentVM GetUpdatedModel() { ContentVM model = new ContentVM(); RepopulateListsFromCacheSession(model); model.Message = ""; if (sessionManager.CurrentContent != null) { model.ContentItem = sessionManager.CurrentContent; } //***************************************NEED WHITE LIST ---- BLACK LIST ------ TO PREVENT OVERPOSTING ************************** bool result = TryUpdateModel(model);//This also validates and sets ModelState //******************************************************************************************************************************* if (sessionManager.CurrentContent != null) { //*****************************************PREVENT OVER POSTING ATTACKS****************************************************** //Get the values for read only fields from session MergeNewValuesWithOriginal(model.ContentItem); //*************************************************************************************************************************** } SetAccessContext(model); return(model); }
public Content BuildContent(ContentVM vm, string id) { return(new Content { Id = id, EnValue = vm.EnValue, FaValue = vm.FaValue, Key = (byte)vm.Key.ToEnum <ContentKey>() }); }
public ActionResult EditingContent_Create(ContentVM model) { model.Content = HttpUtility.HtmlDecode(model.Content); var value = HttpContext.Session.GetString("SessionUser"); UserVM user = JsonConvert.DeserializeObject <UserVM>(value); _contentBusiness.CreateContent(model, user); return(Content("")); }
private void SetFlagsFalse(ContentVM model) { model.IsDeleteConfirmed = "False"; model.IsExitConfirmed = "False"; model.IsNewConfirmed = "False"; //Stop the binder resetting the posted values ModelState.Remove("IsDeleteConfirmed"); ModelState.Remove("IsExitConfirmed"); ModelState.Remove("IsNewConfirmed"); }
public ActionResult Edit() { // Retrieve ID from session string code = sessionManager.ContentCode; ContentVM model = new ContentVM(); // Not from staff or error if (String.IsNullOrEmpty(code)) { //If session has lists then use them RepopulateListsFromCacheSession(model); //Assume we are in create mode as no code passed model.ContentItem = new ContentModel(); } //if we have been passed a code then assume we are in edit situation and we need to retrieve from the database. else { // Create service instance IUcbService sc = UcbService; try { // Call service to get Content item and any associated lookups ContentVMDC returnedObject = sc.GetContent(CurrentUser, CurrentUser, appID, "", code); // Close service communication ((ICommunicationObject)sc).Close(); //Get view model from service model = ConvertContentDC(returnedObject); ResolveFieldCodesToFieldNamesUsingLists(model); //Store the service version sessionManager.ContentServiceVersion = model.ContentItem; } catch (Exception e) { // Handle the exception string message = ExceptionManager.HandleException(e, (ICommunicationObject)sc); model.Message = message; return(View(model)); } } //Adds current retrieved Content to session sessionManager.CurrentContent = model.ContentItem; SetAccessContext(model); return(View(model)); }
private ContentVM ConvertContentDC(ContentVMDC returnedObject) { ContentVM model = new ContentVM(); // Map Content Item model.ContentItem = Mapper.Map <ContentDC, ContentModel>(returnedObject.ContentItem); // Map lookup data lists return(model); }
public ActionResult Index() { ContentVM vm = new ContentVM() { Sliders = db.Sliders.OrderByDescending(x => x.Id).Take(4).OrderBy(x => x.Id).ToList(), Events = db.Events.OrderBy(x => x.DateOfEvent).Take(3).ToList(), Abouts = db.About.ToList(), }; return(View(vm)); }
private void DetermineIsDirty(ContentVM model) { //Compare the Content to the original session if (model.ContentItem.PublicInstancePropertiesEqual(sessionManager.ContentServiceVersion, "RowIdentifier")) { model.IsViewDirty = false; } else { model.IsViewDirty = true; } }
public ActionResult Index() { ContentVM vm = new ContentVM() { Sliders = db.Sliders.OrderByDescending(x => x.Id).Take(3).OrderBy(x => x.Id).ToList(), //Events = db.Events.OrderBy(x => x.DateOfEvent).Take(3).ToList(), Abouts = db.About.ToList(), News = db.News.OrderByDescending(x => x.Id).Take(3).OrderBy(x => x.Id).ToList(), Products = db.Products.OrderByDescending(x => Guid.NewGuid()).Take(8).ToList(), }; return(View(vm)); }
private void SetAccessContext(ContentVM model) { //Decide on access context if (null == model.ContentItem || model.ContentItem.Code == Guid.Empty) { // Create context model.AccessContext = ContentAccessContext.Create; } else { // Edit context model.AccessContext = ContentAccessContext.Edit; } }
public IActionResult Get(int id) { Content _category = _contentRepository.GetSingle(u => u.Id == id); if (_category != null) { ContentVM _categoryVM = Mapper.Map <ContentVM>(_category); return(new OkObjectResult(_categoryVM)); } else { return(NotFound()); } }
public async Task <Message> SaveAsync(ContentVM vm) { var keybyte = (byte)vm.Key.ToEnum <ContentKey>(); if (ctx.Contents.Any(m => m.Key == keybyte)) { var model = ctx.Contents.Where(m => m.Key == keybyte).FirstOrDefault(); if (App.Culture.IsRtl) { model.FaValue = vm.FaValue; } else { model.EnValue = vm.EnValue; } return(await EditAsync(model)); } else { var model = Builder.BuildContent(vm, GenerateId()); return(await AddAsync(model)); } }
public ActionResult EditingContent_Update(ContentVM content) { _contentBusiness.UpdateContent(content); return(Content("")); }
private void ResolveFieldCodesToFieldNamesUsingLists(ContentVM model) { //TODO: }
public async Task <IActionResult> ContentSearchPost(ContentVM model) { return(PartialView("ContentGridView", model)); }
public async Task <IActionResult> CreateContent() { ContentVM result = new ContentVM(); return(PartialView(result)); }
public static string GetValue(this ContentVM content) { var culture = App.Culture.CurrentCulture; return(culture == "fa" ? content.FaValue : content.EnValue); }
public Content BuildContent(ContentVM vm) => BuildContent(vm, vm.Id);