public A4AMailBoxViewModel ListMessage(A4AMailboxType listType) { return(new A4AMailBoxViewModel(Repository.GetMailbox(new MailboxRequest { MailboxType = listType, Owner = GetUserName(), PageSize = 10, Start = 0, UserType = GetUserType() }))); // return new ViewModelListBase(typeof(A4AMessageSummaryViewModel), Repository // .QueryObjects<A4AMessage>() // .Select(x => new A4AMessageSummaryViewModel(x))); }
public IActionResult LoadData2(string userName = "******", A4APartyType partyType = A4APartyType.User, A4AMailboxType mbType = A4AMailboxType.Inbox) { //var userName = HttpContext.Session.GetString(ModelNames.SessionStrings.UserName.ToString()); var mb = new MailboxRequest { Owner = userName, MailboxType = mbType, PageSize = 20, Start = 0, UserType = partyType // HttpContext.Session.GetString(ModelNames.SessionStrings.UserType.ToString()).ToEnum<A4APartyType>() }; return(new ObjectResult(rep.GetMailbox(mb))); }
public ViewModelListBase ListEmailRecord(A4AMailboxType listtype) { return(new ViewModelListBase(typeof(A4AEmailRecordSummaryViewModel), Repository .QueryObjects <A4AEmailRecord>() .Select(x => new A4AEmailRecordSummaryViewModel(x)))); }
public IActionResult EmailManager(string objecttype, string verb, string itemid, A4AMailboxType listtype) { try { objecttype = objecttype ?? ""; verb = verb ?? ""; itemid = itemid ?? ""; Object viewModel = GetAdministrationViewModel(objecttype, verb, itemid, Request.HasFormContentType ? Request.Form : null, listtype); var vm = viewModel as IViewModel; if (vm != null) { vm.ActionNames = ModelNames.ActionNames.EmailManager; } var model = this.model.GetTopicView(); ViewBag.datasource = model.LoadData; return(View(viewModel)); } catch (Exception e) { if (e.InnerException == null) { throw new ApplicationException($"{e.Message} - {e.StackTrace.ToString()}"); } else { throw new ApplicationException($"{e.InnerException.Message} - {e.InnerException.StackTrace.ToString()}"); } } }
Object GetAdministrationViewModel(string objecttype, string verb, string itemid, IFormCollection formCollection, A4AMailboxType listType) { Object viewModel = ""; if (objecttype != "" && !String.IsNullOrEmpty(verb)) { var mi = model.GetType().GetMethod(verb + objecttype); if (mi == null) { throw new Exception( $"Method - {verb}{objecttype} is not found on Model object of type - {model.GetType().Name}"); } if (mi.GetParameters().Length == 0) { viewModel = mi.Invoke(model, null); } else if (mi.GetParameters().Length == 1) { if (mi.GetParameters()[0].ParameterType == typeof(IFormCollection)) { viewModel = mi.Invoke(model, new[] { Request.Form }); } else if (mi.GetParameters()[0].ParameterType == typeof(string)) { viewModel = mi.Invoke(model, new[] { itemid }); } else if (mi.GetParameters()[0].ParameterType == typeof(A4AMailboxType)) { viewModel = mi.Invoke(model, new[] { (object)listType }); } else { throw new Exception( $"Method - {verb}{objecttype} takes an unexpected parameter-type {mi.GetParameters()[0].ParameterType.Name}... "); } } else { throw new Exception( $"Method - {verb}{objecttype} takes more than one parameters - we are currently only able to deal with one... "); } var vm = viewModel as IViewModel; if (vm != null) { vm.Verb = verb.ToEnum <ModelNames.Verb>(); vm.ObjectTypes = objecttype.ToEnum <ModelNames.ObjectTypes>(); } } return(viewModel); }