public ActionResult EditWizard([Bind(Include = "Id,ConcurrencyKey,EntityName,PropertyName,PageName,PageUrlTitle,UIControlName,PageUrl,CommentId,AssociatedApplicationFeedbackTypeID,AssociatedApplicationFeedbackStatusID,ApplicationFeedbackPriorityID,ApplicationFeedbackSeverityID,ApplicationFeedbackResourceID,ReportedBy,ReportedByUser,Summary,Description,AttachImage,AttachDocument")] ApplicationFeedback applicationfeedback, HttpPostedFileBase File_AttachImage, String CamerafileUploadAttachImage, HttpPostedFileBase File_AttachDocument, String CamerafileUploadAttachDocument, string UrlReferrer) { if (ModelState.IsValid) { string path = Server.MapPath("~/Files/"); string ticks = DateTime.UtcNow.Ticks.ToString(); if (File_AttachImage != null) { File_AttachImage.SaveAs(path + ticks + System.IO.Path.GetFileName(File_AttachImage.FileName)); applicationfeedback.AttachImage = ticks + System.IO.Path.GetFileName(File_AttachImage.FileName); } if (File_AttachDocument != null) { File_AttachDocument.SaveAs(path + ticks + System.IO.Path.GetFileName(File_AttachDocument.FileName)); applicationfeedback.AttachDocument = ticks + System.IO.Path.GetFileName(File_AttachDocument.FileName); } db.Entry(applicationfeedback).State = EntityState.Modified; db.SaveChanges(); if (!string.IsNullOrEmpty(UrlReferrer)) { var uri = new Uri(UrlReferrer); var query = HttpUtility.ParseQueryString(uri.Query); if (Convert.ToBoolean(query.Get("IsFilter")) == true) { return(RedirectToAction("Index")); } else { return(Redirect(UrlReferrer)); } } else { return(RedirectToAction("Index")); } } JournalEntryContext jedb = new JournalEntryContext(); ViewBag.JournalEntry = jedb.JournalEntries.Where(p => p.EntityName == "ApplicationFeedback" && p.RecordId == applicationfeedback.Id).ToList(); LoadViewDataAfterOnEdit(applicationfeedback); return(View(applicationfeedback)); }
public JsonResult GetAllValue(string HostingEntityName, string HostingEntity, string HostingEntityID, string ExtraIds) { JournalEntryContext db = new JournalEntryContext(User); IQueryable <JournalEntry> list = db.JournalEntries; ViewData["HostingEntityID"] = HostingEntityID; ViewData["HostingEntity"] = HostingEntity; ViewBag.ExtraIds = ExtraIds; if (HostingEntity != null && HostingEntityID != null) { var hostid = Convert.ToInt64(HostingEntityID); list = list.Where(p => p.EntityName == HostingEntity && p.RecordId == hostid).OrderByDescending(p => p.Id); } if (!string.IsNullOrEmpty(ExtraIds)) { List <long> ids = ExtraIds.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries).Select(Int64.Parse).ToList(); list = db.JournalEntries.Where(p => ids.Contains(p.Id)).Union(list).Distinct().OrderByDescending(p => p.Id); } if (HostingEntityName == "EntityName") { if (HostingEntity != null && FavoriteUrlEntityName != "JournalEntry") { var query = list.Where(x => x.EntityName == HostingEntity) .GroupBy(x => x.EntityName) .OrderByDescending(group1 => group1.Count()).ToList() .Select(grouped => new { Id = grouped.Key, Name = getEntityDisplayName(grouped.Key) }); return(Json(query, JsonRequestBehavior.AllowGet)); } else { var query = from x in list .GroupBy(s => s.EntityName) // groups identical strings into an IGrouping .OrderByDescending(group1 => group1.Count()).ToList() // IGrouping is a collection, so you can count it select new { Id = x.Key, Name = getEntityDisplayName(x.Key) }; return(Json(query, JsonRequestBehavior.AllowGet)); } } if (HostingEntityName == "Type") { var data = from x in list.Select(p => p.Type).Distinct().ToList() select new { Id = x, Name = x }; return(Json(data, JsonRequestBehavior.AllowGet)); } if (HostingEntityName == "UserName") { var query = from x in list .GroupBy(s => s.UserName) // groups identical strings into an IGrouping .OrderByDescending(group1 => group1.Count()).ToList() // IGrouping is a collection, so you can count it select new { Id = x.Key, Name = x.Key }; return(Json(query, JsonRequestBehavior.AllowGet)); } if (HostingEntityName == "PropertyName") { //var data = from x in list.Select(p => p.PropertyName).Distinct().ToList() // select new { Id = x, Name = x }; var query = list.Where(x => x.PropertyName != null && x.EntityName == EntityNameJournal) .GroupBy(x => new { x.PropertyName, x.EntityName }) .OrderByDescending(group1 => group1.Count()).ToList() .Select(grouped => new { Id = grouped.Key.PropertyName, Name = getPropertyDisplayName(grouped.Key.PropertyName, EntityNameJournal) }); return(Json(query, JsonRequestBehavior.AllowGet)); } return(Json(null, JsonRequestBehavior.AllowGet)); }
// public JournalEntryContext db = new JournalEntryContext(User); public ActionResult Index(string currentFilter, string searchString, string sortBy, string isAsc, int?page, int?itemsPerPage, string HostingEntity, int?HostingEntityID, string AssociatedType, bool?IsExport, bool?IsDeepSearch, bool?IsMobileRequest, bool?IsFilter, bool?RenderPartial, string FilterHostingEntityID, string FilterHostingEntity, bool?isHomePage, string ExtraIds) { JournalEntryContext db = new JournalEntryContext(User); if (string.IsNullOrEmpty(isAsc) && !string.IsNullOrEmpty(sortBy)) { isAsc = "ASC"; } ViewBag.isAsc = isAsc; ViewBag.CurrentSort = sortBy; ViewData["HostingEntity"] = HostingEntity; ViewData["HostingEntityID"] = HostingEntityID; ViewData["AssociatedType"] = AssociatedType; ViewData["FilterHostingEntity"] = FilterHostingEntity; ViewData["FilterHostingEntityID"] = FilterHostingEntityID; EntityNameJournal = AssociatedType; ViewData["IsFilter"] = IsFilter.HasValue ? IsFilter.Value : false; if (searchString != null) { page = null; } else { searchString = currentFilter; } ViewBag.CurrentFilter = searchString; var lstJournal = from s in db.JournalEntries select s; if (HostingEntity != null && HostingEntityID != null) { if (isHomePage != null && isHomePage.Value) { lstJournal = lstJournal.Where(p => p.EntityName == HostingEntity && (p.Type == "Modified" || p.Type == "Added" || p.Type == "Deleted") && p.PropertyName != "T_RecordAddedInsertBy" && p.PropertyName != "T_RecordAddedInsertBy" && p.PropertyName != "T_RecordAddedInsertDate" && p.PropertyName != "T_RecordAdded"); lstJournal = lstJournal.GroupBy(p => p.RecordId, (key, g) => g.OrderByDescending(e => e.DateTimeOfEntry).FirstOrDefault()); lstJournal = sortRecords(lstJournal.Where(p => p.Type != "Deleted"), "DateTimeOfEntry", "desc"); lstJournal = lstJournal.Take(5); ViewBag.IsHomePage = isHomePage.Value; } else { lstJournal = new FilteredDbSet <JournalEntry>(db, d => d.Id > 0); lstJournal = lstJournal.Where(p => p.EntityName == HostingEntity && p.RecordId == HostingEntityID).OrderByDescending(p => p.Id); try { Type controller = Type.GetType("GeneratorBase.MVC.Controllers." + HostingEntity + "Controller"); object objController = Activator.CreateInstance(controller, null); System.Reflection.MethodInfo mc = controller.GetMethod("GetExtraJournalEntry"); object[] MethodParams = new object[] { HostingEntityID, User, db }; var obj = mc.Invoke(objController, MethodParams); var listJournal = (IQueryable <JournalEntry>)obj; lstJournal = listJournal.Union(lstJournal).Distinct().OrderByDescending(p => p.Id); } catch {} } } if (FilterHostingEntity != null && FilterHostingEntityID != null) { var hostid = Convert.ToInt64(FilterHostingEntityID); lstJournal = lstJournal.Where(p => p.EntityName == FilterHostingEntity && p.RecordId == hostid).OrderByDescending(p => p.Id); ViewData["HostingEntity"] = FilterHostingEntity; ViewData["HostingEntityID"] = FilterHostingEntityID; } // if (!string.IsNullOrEmpty(ExtraIds)) { List <long> ids = ExtraIds.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries).Select(Int64.Parse).ToList(); lstJournal = db.JournalEntries.Where(p => ids.Contains(p.Id)).Union(lstJournal).Distinct().OrderByDescending(p => p.Id); } // if (!String.IsNullOrEmpty(searchString)) { lstJournal = searchRecords(lstJournal, searchString.ToUpper(), IsDeepSearch); } if ((IsFilter == null ? false : IsFilter.Value) && HostingEntity == "EntityName") { lstJournal = lstJournal.Where(p => p.EntityName == AssociatedType).OrderByDescending(p => p.Id); } if ((IsFilter == null ? false : IsFilter.Value) && HostingEntity == "Type") { lstJournal = lstJournal.Where(p => p.Type == AssociatedType).OrderByDescending(p => p.Id); } if ((IsFilter == null ? false : IsFilter.Value) && HostingEntity == "UserName") { lstJournal = lstJournal.Where(p => p.UserName == AssociatedType).OrderByDescending(p => p.Id); } if ((IsFilter == null ? false : IsFilter.Value) && HostingEntity == "PropertyName") { lstJournal = lstJournal.Where(p => p.PropertyName == AssociatedType).OrderByDescending(p => p.Id); } if (!String.IsNullOrEmpty(sortBy) && !String.IsNullOrEmpty(isAsc) && isHomePage == null) { lstJournal = sortRecords(lstJournal, sortBy, isAsc); } else { lstJournal = lstJournal.OrderByDescending(c => c.Id); } int pageSize = 10; int pageNumber = (page ?? 1); ViewBag.Pages = page; if (itemsPerPage != null) { pageSize = (int)itemsPerPage; ViewBag.CurrentItemsPerPage = itemsPerPage; } var _JournalEntry = lstJournal; if (Convert.ToBoolean(IsExport)) { pageNumber = 1; if (_JournalEntry.Count() > 0) { pageSize = _JournalEntry.Count(); } return(View("ExcelExport", _JournalEntry.ToPagedList(pageNumber, pageSize))); } if (IsMobileRequest != true) { if (Request.AcceptTypes.Contains("text/html")) { if (!(RenderPartial == null ? false : RenderPartial.Value) && !Request.IsAjaxRequest()) { return(View(_JournalEntry.ToPagedList(pageNumber, pageSize))); } else { return(PartialView("IndexPartial", _JournalEntry.ToPagedList(pageNumber, pageSize))); } } else if (Request.AcceptTypes.Contains("application/json")) { var Result = getJournalEntryList(_JournalEntry); return(Json(Result, "application/json", System.Text.Encoding.UTF8, JsonRequestBehavior.AllowGet)); } } else { var Result = getJournalEntryList(_JournalEntry); return(Json(Result, "application/json", System.Text.Encoding.UTF8, JsonRequestBehavior.AllowGet)); } if (!(RenderPartial == null ? false : RenderPartial.Value) && !Request.IsAjaxRequest()) { return(View(_JournalEntry.ToPagedList(pageNumber, pageSize))); } else { return(PartialView("IndexPartial", _JournalEntry.ToPagedList(pageNumber, pageSize))); } }