public async Task <ActionResult> List() { var user = await _userRepository.GetUser(User.Identity.Name); var promos = new List <ResPromoList>(); foreach (var org in user.Organisations) { var organisation = await _organisationRepository.Get(org.ToString()); var orgPromos = await _promoRepository.GetByOrg(org); foreach (var promo in orgPromos) { var status = promo.Status; promos.Add(new ResPromoList { Id = promo.Id, Category = promo.Category, Title = promo.Title, From = promo.From, To = promo.To, OrganisationName = organisation.Name, StatusText = "Draft" }); } } return(View(promos)); }
public ProfilePageModel GetOrganisation(int id) { List <OrganisationSurveyModel> surveys = new List <OrganisationSurveyModel>(); var list = _sr.GetAllSurveysFromOrganisation(id); foreach (var item in list) { OrganisationSurveyModel survey = new OrganisationSurveyModel { ID = item.ID, Title = item.Title }; surveys.Add(survey); } var organisation = _or.Get(id); ProfilePageModel profilePage = new ProfilePageModel { Name = organisation.Name, Email = organisation.Email, Count = _sr.CountSurveyFromOrganisation(id), OrganisationSurvey = surveys }; return(profilePage); }
public async Task <JsonResult> FetchData(ReqData req) { var appModule = await _appModuleRepository.Get(req.AppId); var docTypeService = new DocumentTypeServices(_appModuleRepository); ObjectId documentTypeId; ObjectId.TryParse(req.DocumentTypeId, out documentTypeId); var documentName = await docTypeService.FindDocumentTypeName(req.AppId, documentTypeId); var rootDocumentName = documentName; var org = await _organisationRepository.Get(appModule.OrganisationId); var dataService = new DataService(ConfigurationManager.ConnectionStrings["MongoDB"].ConnectionString, org.Id.ToString(), documentName); //var data = await dataService.Get(dataId, ""); BsonDocument data; if (!string.IsNullOrEmpty(req.SubDocumentTypeId)) { ObjectId subDocumentTypeId; ObjectId.TryParse(req.SubDocumentTypeId, out subDocumentTypeId); documentName = await docTypeService.FindDocumentTypeName(req.AppId, subDocumentTypeId); var subDocumentHierarchy = await docTypeService.FindSubDocumentHierarchy(req.AppId, documentTypeId, documentName, rootDocumentName); data = await dataService.Get(req.DataId, subDocumentHierarchy); } else { data = await dataService.Get(req.DataId); } var jsonWriterSettings = new JsonWriterSettings { OutputMode = JsonOutputMode.Strict }; var result = new JsonGenericResult { IsSuccess = true, Result = data.ToJson(jsonWriterSettings) }; return(Json(result)); }
public async Task <ActionResult> Index() { var response = new ResponseHome(); var promos = new List <ResPromoList>(); var allPromos = await _promoRepository.ListAll(); foreach (var promo in allPromos) { if (promo.Status == "Published") { var organisation = await _organisationRepository.Get(promo.OrganisationId.ToString()); var statusText = promo.Status == null ? "Draft" : promo.Status; promos.Add(new ResPromoList { Id = promo.Id, Category = promo.Category, Title = promo.Title, Price = promo.Price, From = promo.From, To = promo.To, OrganisationName = organisation.Name, MaxNumberOfVoucher = promo.MaxNumberOfVoucher, StatusText = statusText, ShortDescription = promo.ShortDescription, OriginalPrice = promo.OriginalPrice, ImageText = promo.ImageText, Images = promo.Images }); } } if (promos.Any()) { response.Promos = promos; } return(View(response)); }
public async Task <List <Organisation> > Get(string email) { var userOrganisations = new List <Organisation>(); var user = await _userRepository.GetUser(email); if (user != null) { if (user.Organisations != null) { foreach (var organisation in user.Organisations) { var org = await _organisationRepository.Get(organisation.ToString()); if (org != null) { userOrganisations.Add(org); } } } } return(userOrganisations); }
public async Task <JsonResult> Insert(ReqAddData req) { try { if (!string.IsNullOrEmpty(req.appId)) { var appModule = await _appModuleRepository.Get(req.appId); if (appModule != null) { if (appModule.Forms == null) { appModule.Forms = new List <ModuleForm>(); } ObjectId formId; if (ObjectId.TryParse(req.foreignId, out formId)) { var form = appModule.Forms.FirstOrDefault(n => n.Id == formId); var result = new JsonGenericResult { IsSuccess = true, Result = form }; var org = await _organisationRepository.Get(appModule.OrganisationId); var docTypeService = new DocumentTypeServices(_appModuleRepository); var documentName = await docTypeService.FindDocumentTypeName(req.appId, form.DocumentTypeId); var parentDocumentName = documentName == req.ParentDocumentName ? "" : req.ParentDocumentName; var dataService = new DataService(ConfigurationManager.ConnectionStrings["MongoDB"].ConnectionString, org.Id.ToString(), documentName); var serializer = new JavaScriptSerializer(); if (form.SubDocumentTypeId != null && form.SubDocumentTypeId != ObjectId.Empty) { var subDocumentName = await docTypeService.FindDocumentTypeName(req.appId, form.SubDocumentTypeId.Value); var rootDocumentName = await docTypeService.FindDocumentTypeName(req.appId, form.DocumentTypeId); var parentHeirarchy = await docTypeService.FindSubDocumentHierarchy(req.appId, form.DocumentTypeId, subDocumentName, rootDocumentName); parentHeirarchy = parentHeirarchy.Replace(subDocumentName, ""); if (parentHeirarchy.Length > 1) { if (parentHeirarchy.Substring(parentHeirarchy.Length - 1, 1) == ".") { parentHeirarchy = parentHeirarchy.Substring(0, parentHeirarchy.Length - 1); } } //await dataService.Add(req.data, req.RootDataId, subDocumentName, parentDocumentName); await dataService.Add(req.data, req.RootDataId, subDocumentName, parentHeirarchy); } else { dataService.Add(req.data); } return(Json(result)); } } } var ErrorResult = new JsonGenericResult { IsSuccess = false, Message = "No app selected." }; return(Json(ErrorResult)); } catch (Exception ex) { return(Json(new JsonGenericResult { IsSuccess = false, Message = ex.Message })); } }
public async Task <Organisation> Get(string id) { var organisation = await _organisationRepository.Get(id); return(organisation); }