public static ClientModel Build(int ClientId, DASEntities db) { //ClientModel model = new ClientModel(); ClientModel model = db.Clients.Where(a => a.ClientId == ClientId).Select(a => new ClientModel() { ClientName = a.Name, Description = a.Description, Address = a.Address, ClientId = a.ClientId }).FirstOrDefault(); model.Certificates = new List <CertModel>(); IList <Certificate> certs = db.Certificates.Where(j => j.ClientId == ClientId).ToList(); CertModel temp; foreach (var item in certs) { temp = new CertModel() { CertId = item.CertificateId, CertName = item.CertificateName, Standard = item.Standard }; temp.Status = GetStatusName(db, item.StatusId); temp.Statuses = BuildStatuses(db); temp.StatusID = item.StatusId; model.Certificates.Add(temp); } return(model); }
public static IList <NewsModel> BuildCurrentNews(DASEntities db) { int languageId = (int)HttpContext.Current.Session["lngId"]; IList <NewsModel> model = db.News.Where(l => l.LanguageId == languageId && l.Archive == false).Select(n => new NewsModel() { NewsId = n.NewsId, Name = n.Name, Text = n.Text, Year = n.Year, Ord = n.Ord, Archive = n.Archive, LanguageId = n.LanguageId }).OrderByDescending(l => l.Year).ThenBy(l => l.Ord).ToList(); return(model); }
public static ApplicationList FilterApplications(DASEntities db, GridDescriptor desc, ApplicationListFilterModel filters) { ApplicationList model = new ApplicationList() { Descriptor = desc, ListOfApplication = new List <DAS.Backoffice.Models.Application.ApplicationForm>() }; IQueryable <DAS.Domain.Model.ApplicationForm> applications = db.ApplicationForms.AsQueryable(); int languageId = (int)HttpContext.Current.Session["lngId"]; if (filters == null) { filters = new ApplicationListFilterModel(); } string filApplication = ""; if (!string.IsNullOrWhiteSpace(filters.Name)) { filApplication = filters.Name.Replace(":", "").Replace("/", "").Replace("-", "").Replace("–", "").Replace("\"", "").Replace(".", ""); applications = applications.Where(m => m.CompanyName.Contains(filApplication)); } IList <DAS.Domain.Model.ApplicationForm> listA = applications.Slice(desc).ToList(); DAS.Backoffice.Models.Application.ApplicationForm applicationModel; foreach (var item in listA) { applicationModel = new DAS.Backoffice.Models.Application.ApplicationForm() { ApplicationId = item.ApllicationId, CompanyName = item.CompanyName, Adress = item.Adress, Place = item.Place, Telephone = item.Telephone, Email = item.Email, Applicant = item.Applicant, ISO14001 = (bool)item.ISO14001, ISO22301 = (bool)item.ISO22301, ISO27001 = (bool)item.ISO27001, ISO9001 = (bool)item.ISO9001, OtherIso = (bool)item.OtherIso, Other = item.Other, CompanyWebsite = item.CompanyWebsite, PrimaryContactForAuditPurposes = item.PrimaryContactForAuditPurposes, PrimaryContactTelephone = item.PrimaryContactTelephone, NatureOfBusiness = item.NatureOfBusiness, NumberOfYearsAtThisSite = item.NumberOfYearsAtThisSite, PrincipleServicesOrProducts = item.PrincipleServicesOrProducts, ActivitiesOnClientsSites = item.ActivitiesOnClientsSites, NameOfPresentCertificationBody = item.NameOfPresentCertificationBody, CertificateExpiryDate = item.CertificateExpiryDate, TotalNumberOfEmployees = item.TotalNumberOfEmployees, TotalNumberOfCompanyDirectors = item.TotalNumberOfCompanyDirectors, NumberOfLocations = item.NumberOfLocations, AllSitesMainActivites = item.AllSitesMainActivites, SalesTotalPermanent = item.SalesTotalPermanent, SalesTotalTemporary = item.SalesTotalTemporary, MarketingTotalPermanent = item.MarketingTotalPermanent, MarketingTotalTemporary = item.MarketingTotalTemporary, AdministrationTotalPermanent = item.AdministrationTotalPermanent, AdministrationTotalTemporary = item.AdministrationTotalTemporary, DesignTotalPermanent = item.DesignTotalPermanent, DesignTotalTemporary = item.DesignTotalTemporary, ManufacturingTotalPermanent = item.ManufacturingTotalPermanent, ManufacturingTotalTemporary = item.ManufacturingTotalTemporary, OtherTotalPermanent = item.OtherTotalPermanent, OtherTotalTemporary = item.OtherTotalTemporary, TotalPermanent = item.TotalPermanent, TotalTemporary = item.TotalTemporary, Extension = item.Extension, ManagementRepresentativeName = item.ManagementRepresentativeName, JobTitle = item.JobTitle, NameOfConsultant = item.NameOfConsultant, ConsultantTelephone = item.ConsultantTelephone, ISO14001_2 = (bool)item.ISO14001_2, ISO9001_2 = (bool)item.ISO9001_2, ISO22301_2 = (bool)item.ISO22301_2, ISO27001_2 = (bool)item.ISO27001_2, BSOHSAS18001_2 = (bool)item.BSOHSAS18001_2, StandardTransferred = item.StandardTransferred, DateNextCertificationBodyVisit = item.DateNextCertificationBodyVisit, Other_2 = item.Other_2, OtherIso_2 = (bool)item.OtherIso_2, date_created = (DateTime)item.DateCreated }; model.ListOfApplication.Add(applicationModel); } return(model); }
public static string GetStatusName(DASEntities db, int statusId) { int languageId = (int)HttpContext.Current.Session["lngId"]; string name = db.Status.FirstOrDefault(m => m.StatusId == statusId).Name; if (languageId != 1) { DAS.Domain.Model.Status_Lng tran = db.Status_Lng.FirstOrDefault(n => n.LanguageId == languageId && n.StatusId == statusId); if (tran != null) { name = tran.Name; } } return(name); }
protected override IList <LanguageDTO> LoadFromDB() { using (DASEntities db = new DASEntities()) { List <LanguageDTO> languages = new List <LanguageDTO>(); IQueryable <Language> dbLanguages = db.Languages.OrderBy(lng => lng.LanguageId); foreach (var dbLanguage in dbLanguages) { languages.Add(new LanguageDTO() { LanguageId = dbLanguage.LanguageId, Name = dbLanguage.Name }); } return(languages); } }
public static string GetLabel(string viewId, string elementId) { string imagesPath = WebConfigurationManager.AppSettings["imagesPath"]; if (HttpContext.Current.Session["lngId"] == null) { HttpContext.Current.Session["lngId"] = 1; } ; Dictionary <string, string> viewLabels; if (labels.Data.ContainsKey(viewId)) { viewLabels = labels.Data[viewId]; } else { viewLabels = new Dictionary <string, string>(); DASEntities db = new DASEntities(); var dbLabels = db.Labels.Where(lb => lb.ViewId == viewId); if (!dbLabels.Any()) { throw new Exception("Invalid viewId"); } foreach (var dbLabel in dbLabels) { if (viewId == "Home") { viewLabels.Add(dbLabel.ElementId + "_" + dbLabel.LanguageId, dbLabel.Text.Replace("../Content/", imagesPath)); } else { viewLabels.Add(dbLabel.ElementId + "_" + dbLabel.LanguageId, dbLabel.Text); } // viewLabels.Add(dbLabel.ElementId + "_" + dbLabel.LanguageId, dbLabel.Text.Replace("../Content/", "../DAS/Content/")); } } string labelKey = elementId + "_" + HttpContext.Current.Session["lngId"]; if (!viewLabels.ContainsKey(labelKey) && (int)HttpContext.Current.Session["lngId"] != 1) { labelKey = elementId + "_1"; } return(viewLabels[labelKey]); }
public static ApplicationsModel BuildApplications(DASEntities db) { ApplicationsModel model = new ApplicationsModel(); int languageId = (int)HttpContext.Current.Session["lngId"]; GridDescriptor desc = new GridDescriptor(new SortDescriptor() { PropertyName = "DateCreated", Order = SortOrder.Descending }) { Pager = new PagerDescriptor(1, 20, db.Labels.Where(l => l.ViewId == "Clients" && l.ElementId == "lblPageSize" && l.LanguageId == languageId).Select(l => l.Text).FirstOrDefault(), 5) }; IQueryable <DAS.Domain.Model.ApplicationForm> applications = db.ApplicationForms.AsQueryable(); IList <DAS.Domain.Model.ApplicationForm> listA = applications.Slice(desc).ToList(); model.Filters = new ApplicationListFilterModel(); model.Applications = new ApplicationList() { Descriptor = desc, ListOfApplication = new List <DAS.Backoffice.Models.Application.ApplicationForm>() }; DAS.Backoffice.Models.Application.ApplicationForm applicationModel; foreach (var item in listA) { applicationModel = new DAS.Backoffice.Models.Application.ApplicationForm() { ApplicationId = item.ApllicationId, CompanyName = item.CompanyName, Adress = item.Adress, Place = item.Place, Telephone = item.Telephone, Email = item.Email, Applicant = item.Applicant, ISO14001 = (bool)item.ISO14001, ISO22301 = (bool)item.ISO22301, ISO27001 = (bool)item.ISO27001, ISO9001 = (bool)item.ISO9001, OtherIso = (bool)item.OtherIso, Other = item.Other, CompanyWebsite = item.CompanyWebsite, PrimaryContactForAuditPurposes = item.PrimaryContactForAuditPurposes, PrimaryContactTelephone = item.PrimaryContactTelephone, NatureOfBusiness = item.NatureOfBusiness, NumberOfYearsAtThisSite = item.NumberOfYearsAtThisSite, PrincipleServicesOrProducts = item.PrincipleServicesOrProducts, ActivitiesOnClientsSites = item.ActivitiesOnClientsSites, NameOfPresentCertificationBody = item.NameOfPresentCertificationBody, CertificateExpiryDate = item.CertificateExpiryDate, TotalNumberOfEmployees = item.TotalNumberOfEmployees, TotalNumberOfCompanyDirectors = item.TotalNumberOfCompanyDirectors, NumberOfLocations = item.NumberOfLocations, AllSitesMainActivites = item.AllSitesMainActivites, SalesTotalPermanent = item.SalesTotalPermanent, SalesTotalTemporary = item.SalesTotalTemporary, MarketingTotalPermanent = item.MarketingTotalPermanent, ManufacturingTotalTemporary = item.ManufacturingTotalTemporary, MarketingTotalTemporary = item.MarketingTotalTemporary, AdministrationTotalPermanent = item.AdministrationTotalPermanent, AdministrationTotalTemporary = item.AdministrationTotalTemporary, DesignTotalPermanent = item.DesignTotalPermanent, DesignTotalTemporary = item.DesignTotalTemporary, ManufacturingTotalPermanent = item.ManufacturingTotalPermanent, OtherTotalPermanent = item.OtherTotalPermanent, OtherTotalTemporary = item.OtherTotalTemporary, TotalPermanent = item.TotalPermanent, TotalTemporary = item.TotalTemporary, Extension = item.Extension, ManagementRepresentativeName = item.ManagementRepresentativeName, JobTitle = item.JobTitle, NameOfConsultant = item.NameOfConsultant, ConsultantTelephone = item.ConsultantTelephone, ISO14001_2 = (bool)item.ISO14001_2, ISO9001_2 = (bool)item.ISO9001_2, ISO22301_2 = (bool)item.ISO22301_2, ISO27001_2 = (bool)item.ISO27001_2, BSOHSAS18001_2 = (bool)item.BSOHSAS18001_2, StandardTransferred = item.StandardTransferred, DateNextCertificationBodyVisit = item.DateNextCertificationBodyVisit, Other_2 = item.Other_2, OtherIso_2 = (bool)item.OtherIso_2, date_created = (DateTime)item.DateCreated }; model.Applications.ListOfApplication.Add(applicationModel); } return(model); }
public static IList <StatusModel> BuildStatuses(DASEntities db) { IList <StatusModel> list; int languageId = (int)HttpContext.Current.Session["lngId"]; if (languageId == 1) { list = db.Status.Select(m => new StatusModel() { StatusId = m.StatusId, StatusName = m.Name }).ToList(); } else { list = db.Status_Lng.Where(n => n.LanguageId == languageId).Select(l => new StatusModel() { StatusId = l.StatusId, StatusName = l.Name }).ToList(); } return(list); }
public static IList <NewsModel> BuildArchivedNews(DASEntities db, int ArchiveId) { int languageId = (int)HttpContext.Current.Session["lngId"]; Archive temp = db.Archives.Include("News").Where(j => j.ArchiveId == ArchiveId).FirstOrDefault(); IList <NewsModel> list = new List <NewsModel>(); foreach (News tempC in temp.News) { if (languageId == tempC.LanguageId) { NewsModel news = new NewsModel() { NewsId = tempC.NewsId, Name = tempC.Name, Text = tempC.Text, Year = tempC.Year, Ord = tempC.Ord, Archive = tempC.Archive, LanguageId = tempC.LanguageId }; list.Add(news); } } return(list); }
public static NewsListModel BuildNews(DASEntities db) { NewsListModel model = new NewsListModel(); int languageId = (int)HttpContext.Current.Session["lngId"]; model.NewsList = db.News.Where(l => l.LanguageId == languageId && l.Archive == false).Select(n => new NewsModel() { NewsId = n.NewsId, Name = n.Name, Text = n.Text, Year = n.Year, Ord = n.Ord, Archive = n.Archive, LanguageId = n.LanguageId }).OrderByDescending(l => l.Year).ThenByDescending(l => l.Ord).ToList(); IList <int> pomArch = db.News.Include("Archive").Where(l => l.LanguageId == languageId && l.Archive == true).Select(k => k.Archives.FirstOrDefault().ArchiveId).Distinct().ToList(); string archiveLbl = LabelCache.GetLabel("Home", "lblArchive"); string newsLbl = LabelCache.GetLabel("Home", "lblNovosti"); var list = db.Archives.OrderByDescending(l => l.Year).ToList(); model.ArchiveList = new List <ArchiveModel>(); foreach (var item in pomArch) { Archive temp = list.OrderByDescending(m => m.Year).FirstOrDefault(b => b.ArchiveId == item); model.ArchiveList.Add(new ArchiveModel() { ArchiveId = temp.ArchiveId, Name = archiveLbl + " " + temp.Year }); } model.ArchiveList.Add(new ArchiveModel() { ArchiveId = 0, Name = newsLbl }); model.ArchiveList = model.ArchiveList.OrderByDescending(m => m.ArchiveId).ToList(); model.SelectedArchiveId = 0; return(model); }
public static string GetLabel(string viewId, string elementId) { if (HttpContext.Current.Session["lngId"] == null) { HttpContext.Current.Session["lngId"] = 1; } ; Dictionary <string, string> viewLabels; if (labels.Data.ContainsKey(viewId)) { viewLabels = labels.Data[viewId]; } else { viewLabels = new Dictionary <string, string>(); DASEntities db = new DASEntities(); var dbLabels = db.Labels.Where(lb => lb.ViewId == viewId); if (!dbLabels.Any()) { throw new Exception("Invalid viewId"); } foreach (var dbLabel in dbLabels) { viewLabels.Add(dbLabel.ElementId + "_" + dbLabel.LanguageId, dbLabel.Text); } } string labelKey = elementId + "_" + HttpContext.Current.Session["lngId"]; if (!viewLabels.ContainsKey(labelKey) && (int)HttpContext.Current.Session["lngId"] != 1) { labelKey = elementId + "_1"; } return(viewLabels[labelKey]); }
public static bool Send(DASEntities db, ApplicationForm model) { int lngId = (int)HttpContext.Current.Session["lngId"]; try { string ServerIP = WebConfigurationManager.AppSettings["MailServerIP"]; string ServerUsername = WebConfigurationManager.AppSettings["MailServerUsername"]; string ServerPassword = WebConfigurationManager.AppSettings["MailServerPassword"]; int ServerPort = Int32.Parse(WebConfigurationManager.AppSettings["MailServerPort"]); string DefaultMailAddress = WebConfigurationManager.AppSettings["DefaultMailAddress"]; string ReceiverMailAddress = model.Email; string ReceiverCCMailAddress = WebConfigurationManager.AppSettings["ReceiverMailAddress"]; Postman postman = new Postman(ServerIP, ServerUsername, ServerPassword, ServerPort); string bodyText; if (lngId == 1) { bodyText = "Poštovani/a,<br/><br/>"; bodyText += "Vaša aplikacija je primljena. Ponudu ćete dobiti u roku od 72h ili će vas kontaktirati neko iz DAS SEE kancelarije.<br/><br/>"; bodyText += "S poštovanjem,<br/>"; bodyText += "DAS SEE Office<br/>"; bodyText += "[email protected]<br/>"; bodyText += "www.das-see.com<br/>"; } else if (lngId == 2) { bodyText = "Почитувани/а,<br/><br/>"; bodyText += "Вашата апликација е примена. Ќе добиете понуда во рок од 72 часа или ќе ве контактират некој од канцеларијата на DAS SEE officе.<br/><br/>"; bodyText += "Со почит,<br/>"; bodyText += "DAS SEE Office<br/>"; bodyText += "[email protected]<br/>"; bodyText += "www.das-see.com<br/>"; } else if (lngId == 3) { bodyText = "Poštovani/a,<br/><br/>"; bodyText += "Vaša aplikacija je primljena. Ponudu ćete dobiti u roku od 72h ili će vas kontaktirati neko iz DAS SEE ureda.<br/><br/>"; bodyText += "S poštovanjem,<br/>"; bodyText += "DAS SEE Office<br/>"; bodyText += "[email protected]<br/>"; bodyText += "www.das-see.com<br/>"; } else { bodyText = "Dear Sir/Madam,<br/><br/>"; bodyText += "Your application is received. You will get an offer within 72 hours or you will be contacted by someone from the DAS SEE office.<br/><br/>"; bodyText += "Best regards,<br/>"; bodyText += "DAS SEE Office<br/>"; bodyText += "[email protected]<br/>"; bodyText += "www.das-see.com<br/>"; } StringBuilder body = new StringBuilder(string.Format(EmailWrapper, bodyText)); //container for every mail postman.SetFrom(DefaultMailAddress); postman.AddToList(ReceiverMailAddress); postman.AddCC(ReceiverCCMailAddress); if (lngId == 1) { postman.Subject = "Zahtev za ponudu: " + model.CompanyName; } else if (lngId == 2) { postman.Subject = "Барање за понуда: " + model.CompanyName; } else if (lngId == 3) { postman.Subject = "Zahtjev za ponudu: " + model.CompanyName; } else { postman.Subject = "Request for offer: " + model.CompanyName; } postman.Body = body.ToString(); postman.SendMail(); return(true); } catch (Exception) { return(false); throw; } }
internal static bool Send(DASEntities Db, Models.Application.ApplicationForm model) { throw new NotImplementedException(); }
public static ClientList FilterClients(DASEntities db, GridDescriptor desc, FilterModel filters) { ClientList model = new ClientList() { Descriptor = desc, ListOfClients = new List <ClientModel>() }; IQueryable <Client> clients = db.Clients.AsQueryable(); IQueryable <vw_ClientsBackoffice> clientsF = db.vw_ClientsBackoffice.AsQueryable(); string filStandard = ""; if (filters == null) { filters = new FilterModel(); } if (!string.IsNullOrWhiteSpace(filters.Name)) { filStandard = filters.Name.Replace(":", "").Replace("/", "").Replace("-", "").Replace("–", "").Replace("\"", "").Replace(".", ""); clientsF = clientsF.Where(m => m.Name.Contains(filStandard)); } if (filters.SelectedStatusId != 0) { if (!string.IsNullOrWhiteSpace(filters.Standard)) { clientsF = clientsF.Where(b => b.StatusId == filters.SelectedStatusId && b.Standard.Contains(filters.Standard)); } else { clientsF = clientsF.Where(m => m.StatusId == filters.SelectedStatusId); } } else if (!string.IsNullOrWhiteSpace(filters.Standard)) { clientsF = clientsF.Where(m => m.Standard.Contains(filters.Standard)); } IList <int> clientIds = clientsF.Select(k => k.ClientId).Distinct().ToList(); IList <Client> listC = clients.Where(h => clientIds.Contains(h.ClientId)).Slice(desc).ToList(); ClientModel clientM; CertModel certM; foreach (var item in listC) { clientM = new ClientModel() { ClientId = item.ClientId, Address = item.Address, ClientName = item.Name, Description = item.Description, Certificates = new List <CertModel>() }; foreach (var itemC in item.Certificates) { if ((string.IsNullOrWhiteSpace(filters.Standard) || itemC.Standard.Contains(filters.Standard.ToUpper())) && (filters.SelectedStatusId == 0 || filters.SelectedStatusId == itemC.StatusId)) { certM = new CertModel() { CertId = itemC.CertificateId, CertName = itemC.CertificateName, Standard = itemC.Standard }; certM.Status = GetStatusName(db, itemC.StatusId); clientM.Certificates.Add(certM); } } model.ListOfClients.Add(clientM); } return(model); }
public static ClientsModel BuildClients(DASEntities db) { ClientsModel model = new ClientsModel(); int languageId = (int)HttpContext.Current.Session["lngId"]; model.Filters = new FilterModel(); model.Filters.Statuses = BuildStatuses(db); /*todo; dodati labelu Svi u labels*/ string stat = "..."; stat = db.Labels.Where(s => s.ViewId == "Clients" && s.ElementId == "lblSearchStat" && s.LanguageId == languageId).Select(ps => ps.Text).FirstOrDefault(); model.Filters.Statuses.Add(new StatusModel() { StatusId = 0, StatusName = stat }); /*in backoffice selected status is All*/ model.Filters.SelectedStatusId = 0; model.Filters.Statuses = model.Filters.Statuses.OrderBy(m => m.StatusId).ToList(); GridDescriptor desc = new GridDescriptor(new SortDescriptor() { PropertyName = "DateChange", Order = SortOrder.Descending }) { Pager = new PagerDescriptor(1, 20, db.Labels.Where(l => l.ViewId == "Clients" && l.ElementId == "lblPageSize" && l.LanguageId == languageId).Select(l => l.Text).FirstOrDefault(), 5) }; IQueryable <Client> clients = db.Clients.AsQueryable(); /*initial filter will be only with active status*/ //clients = clients.Where(m => m.Certificates.Any(l => l.StatusId == 1)); IList <Client> listC = clients.Slice(desc).ToList(); model.Clients = new ClientList() { Descriptor = desc, ListOfClients = new List <ClientModel>() }; ClientModel clientM; CertModel certM; foreach (var item in listC) { clientM = new ClientModel() { ClientId = item.ClientId, Address = item.Address, ClientName = item.Name, Description = item.Description, Certificates = new List <CertModel>() }; foreach (var itemC in item.Certificates) { //if (itemC.StatusId==1) //{ certM = new CertModel() { CertId = itemC.CertificateId, CertName = itemC.CertificateName, Standard = itemC.Standard }; certM.Status = GetStatusName(db, itemC.StatusId); clientM.Certificates.Add(certM); //} } model.Clients.ListOfClients.Add(clientM); } return(model); }