public ActionResult Add(LegalEntityOwnerView legalEntityOwnerView, FormCollection form) { if (ModelState.IsValid) { ILegalEntityOwnersRepository legalEntityOwnersRepository = new LegalEntityOwnersRepository(db); LegalEntityOwner legalEntityOwner = new LegalEntityOwner(); legalEntityOwnerView.ConvertTo(legalEntityOwnerView, legalEntityOwner); legalEntityOwnersRepository.Add(legalEntityOwner); legalEntityOwnersRepository.SaveChanges(); TempData["message"] = LayoutHelper.GetMessage("INSERT", legalEntityOwner.LegalEntityOwnerPK); if (TempData["legalEntityFK"] != null) { return(RedirectToAction("Index", "LegalEntity")); } else { return(RedirectToAction("Index", "LegalEntityOwner")); } } else { legalEntityOwnerView.BindDLLs(legalEntityOwnerView, db); return(View(legalEntityOwnerView)); } }
public FileContentResult ShowLegalEntityOwnersGraph(int?legalEntityFK, string color, int?dpi) { ILegalEntitiesRepository legalEntitiesRepository = new LegalEntitiesRepository(db); ILegalEntityOwnersRepository legalEntityOwnersRepository = new LegalEntityOwnersRepository(db); IPhysicalEntitiesRepository physicalEntitiesRepository = new PhysicalEntitiesRepository(db); List <LegalEntityOwner> filteredCoList = new List <LegalEntityOwner>(); IQueryable <LegalEntityOwner> legalEntityOwnersTable = legalEntityOwnersRepository.GetValid(); if (legalEntityFK != null) { List <LegalEntityOwner> coList = new List <LegalEntityOwner>(); coList = legalEntityOwnersRepository.GetFirstLegalEntityOwnersForLegalEntity((int)legalEntityFK).ToList(); foreach (var co in coList) { LegalEntityOwnerView.Fill(filteredCoList, legalEntityOwnersTable.ToList(), co); } legalEntityOwnersTable = filteredCoList.AsQueryable(); } IQueryable <LegalEntityOwnerView> legalEntityOwners = LegalEntityOwnerView.GetLegalEntityOwnerView(legalEntityOwnersTable, physicalEntitiesRepository.GetValid(), legalEntitiesRepository.GetValid()); List <string> graphElements = new List <string>(); foreach (LegalEntityOwnerView item in legalEntityOwners) { graphElements.Add(item.OwnerFK.ToString() + "[label=\"" + item.OwnerName + "\", shape=ci, fontsize=12, fontname=arial, labelloc=t, style=filled, fillcolor=\"white\", width=1.5]"); if (legalEntityFK == item.LegalEntityFK) { graphElements.Add(item.LegalEntityFK.ToString() + "[label=\"" + item.LegalEntityName + "\", shape=box, fontsize=12, fontname=arial, labelloc=t, style=filled, fontcolor=\"white\", color=\"black\", width=1.5]"); } else { graphElements.Add(item.LegalEntityFK.ToString() + "[label=\"" + item.LegalEntityName + "\", shape=box, fontsize=12, fontname=arial, labelloc=t, style=filled, fillcolor=\"white\", width=1.5]"); } graphElements.Add(item.OwnerFK.ToString() + "->" + item.LegalEntityFK.ToString()); } string graph = @"digraph Graphviz {"; graph += "[bgcolor=\"" + color + "\", dpi=\"" + dpi + "\"],"; graph += string.Join(", ", graphElements.ToArray()); graph += "}"; graph = graph.ConvertNonASCIICharacters(); byte[] imageByte = imageByte = Graphviz.RenderImage(graph, "dot", "png");; string contentType = "image/png"; return(File(imageByte, contentType)); }
public ActionResult Delete(int?legalEntityOwnerPK) { ILegalEntityOwnersRepository legalEntityOwnersRepository = new LegalEntityOwnersRepository(db); if (legalEntityOwnerPK != null) { LegalEntityOwner legalEntityOwner = legalEntityOwnersRepository.GetLegalEntityOwnerByPK((int)legalEntityOwnerPK); legalEntityOwner.Deleted = true; legalEntityOwnersRepository.SaveChanges(); TempData["message"] = LayoutHelper.GetMessage("DELETE", legalEntityOwner.LegalEntityOwnerPK); } return(Redirect(Request.UrlReferrer.AbsoluteUri)); }
public ActionResult Edit(int?legalEntityOwnerPK) { if (legalEntityOwnerPK != null) { ILegalEntityOwnersRepository legalEntityOwnersRepository = new LegalEntityOwnersRepository(db); LegalEntityOwner legalEntityOwner = legalEntityOwnersRepository.GetLegalEntityOwnerByPK((int)legalEntityOwnerPK); LegalEntityOwnerView legalEntityOwnerView = new LegalEntityOwnerView(); legalEntityOwnerView.ConvertFrom(legalEntityOwner, legalEntityOwnerView, db); legalEntityOwnerView.BindDLLs(legalEntityOwnerView, db); return(View(legalEntityOwnerView)); } else { return(RedirectToAction("Index", "LegalEntityOwner")); } }
public static List <List <LegalEntityOwnerAuditView> > GetLegalEntityOwnersAuditView(ObjectContext context, int legalEntityFK) { ILegalEntitiesRepository legalEntitiesRepository = new LegalEntitiesRepository(context); IPhysicalEntitiesRepository physicalEntitiesRepository = new PhysicalEntitiesRepository(context); ILegalEntityOwnersRepository legalEntityOwnersRepository = new LegalEntityOwnersRepository(context); // get all legalEntity branches List <LegalEntityOwnerView> legalEntityOwners = LegalEntityOwnerView.GetLegalEntityOwnerView(legalEntityOwnersRepository.GetAll(), physicalEntitiesRepository.GetValid(), legalEntitiesRepository.GetValid()) .Where(c => c.LegalEntityFK == legalEntityFK) .ToList(); List <List <LegalEntityOwnerAuditView> > legalEntityOwnersListList = new List <List <LegalEntityOwnerAuditView> >(); foreach (LegalEntityOwnerView legalEntityOwner in legalEntityOwners) { legalEntityOwnersListList.Add(LegalEntityOwnerAuditView.GetLegalEntityOwnerAuditView(context, legalEntityOwner.LegalEntityOwnerPK)); } return(legalEntityOwnersListList); }
public ActionResult Edit(LegalEntityOwnerView legalEntityOwnerView, FormCollection form) { if (ModelState.IsValid) { ILegalEntityOwnersRepository legalEntityOwnersRepository = new LegalEntityOwnersRepository(db); LegalEntityOwner legalEntityOwner = legalEntityOwnersRepository.GetLegalEntityOwnerByPK((int)legalEntityOwnerView.LegalEntityOwnerPK); legalEntityOwnerView.ConvertTo(legalEntityOwnerView, legalEntityOwner); legalEntityOwnersRepository.SaveChanges(); TempData["message"] = LayoutHelper.GetMessage("UPDATE", legalEntityOwner.LegalEntityOwnerPK); return(RedirectToAction("Index", "LegalEntityOwner")); } else { legalEntityOwnerView.BindDLLs(legalEntityOwnerView, db); return(View(legalEntityOwnerView)); } }
public ActionResult Index() { ILegalEntityOwnersRepository legalEntityOwnersRepository = new LegalEntityOwnersRepository(db); ILegalEntitiesRepository legalEntitiesRepository = new LegalEntitiesRepository(db); IPhysicalEntitiesRepository physicalEntitiesRepository = new PhysicalEntitiesRepository(db); int page = !String.IsNullOrWhiteSpace(Request.QueryString["page"]) ? Convert.ToInt32(Request.QueryString["page"]) : 1; int pageSize = !String.IsNullOrWhiteSpace(Request.QueryString["pageSize"]) ? Convert.ToInt32(Request.QueryString["pageSize"]) : Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["ResultsPerPage"]); string sortOrder = !String.IsNullOrWhiteSpace(Request.QueryString["sortOrder"]) ? Request.QueryString["sortOrder"] : "DESC"; string sortColumn = !String.IsNullOrWhiteSpace(Request.QueryString["sortColumn"]) ? Request.QueryString["sortColumn"] : "LegalEntityOwnerPK"; string ordering = sortColumn + " " + sortOrder; ordering = ordering.Trim(); List <LegalEntityOwner> filteredCoList = new List <LegalEntityOwner>(); IQueryable <LegalEntityOwner> legalEntityOwnersTable = legalEntityOwnersRepository.GetValid(); //if (!String.IsNullOrWhiteSpace(Request.QueryString["legalEntityFK"])) //{ // List<LegalEntityOwner> coList = new List<LegalEntityOwner>(); // coList = legalEntityOwnersRepository.GetFirstLegalEntityOwnersForLegalEntity(Convert.ToInt32(Request.QueryString["legalEntityFK"])).ToList(); // foreach (var co in coList) // { // LegalEntityOwnerView.Fill(filteredCoList, legalEntityOwnersTable.ToList(), co); // } // legalEntityOwnersTable = filteredCoList.AsQueryable(); //} IQueryable <LegalEntityOwnerView> legalEntityOwners = LegalEntityOwnerView.GetLegalEntityOwnerView(legalEntityOwnersTable, physicalEntitiesRepository.GetValid(), legalEntitiesRepository.GetValid()) .OrderBy(ordering); //LegalEntities ddl ViewBag.LegalEntities = new SelectList(legalEntitiesRepository.GetValid().OrderBy("Name ASC").ToList(), "LegalEntityPK", "Name", Request.QueryString["legalEntityFK"]); if (!String.IsNullOrWhiteSpace(Request.QueryString["legalEntityFK"])) { int legalEntityFK = Convert.ToInt32(Request.QueryString["legalEntityFK"]); legalEntityOwners = legalEntityOwners.Where(c => c.LegalEntityFK == legalEntityFK); } if (!String.IsNullOrWhiteSpace(Request.QueryString["searchString"])) { string searchString = Request.QueryString["searchString"].ToString(); legalEntityOwners = legalEntityOwners.Where(c => c.OwnerName.Contains(searchString)); } if (!String.IsNullOrWhiteSpace(Request.QueryString["searchString"])) { string searchString = Request.QueryString["searchString"].ToString(); ViewData["numberOfRecords"] = legalEntityOwners.Where(c => c.OwnerName.Contains(searchString)).Count(); } else { ViewData["numberOfRecords"] = legalEntityOwners.Count(); } legalEntityOwners = legalEntityOwners.Page(page, pageSize); int numberOfPages = ((int)ViewData["numberOfRecords"] + pageSize - 1) / pageSize; if (page > numberOfPages) { string url = LinkHelper.getQueryStringArray(new string[] { "page" }); return(Redirect("LegalEntityOwner?" + url + "page=" + numberOfPages)); } else { return(View("Index", legalEntityOwners.ToList())); } }
public ActionResult Index() { ILegalEntitiesRepository legalEntitiesRepository = new LegalEntitiesRepository(db); IContractsRepository contractsRepository = new ContractsRepository(db); ILegalEntityBranchesRepository legalEntityBranchesRepository = new LegalEntityBranchesRepository(db); IBanksRepository banksRepository = new BanksRepository(db); ILegalEntityBanksRepository legalEntitiesBanksRepository = new LegalEntityBanksRepository(db); ILegalEntityLegalRepresentativesRepository legalEntityLegalRepresentativesRepository = new LegalEntityLegalRepresentativesRepository(db); ILegalEntityOwnersRepository legalEntityOwnersRepository = new LegalEntityOwnersRepository(db); IAssessmentsRepository assessmentsRepository = new AssessmentsRepository(db); int page = !String.IsNullOrWhiteSpace(Request.QueryString["page"]) ? Convert.ToInt32(Request.QueryString["page"]) : 1; int pageSize = !String.IsNullOrWhiteSpace(Request.QueryString["pageSize"]) ? Convert.ToInt32(Request.QueryString["pageSize"]) : Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["ResultsPerPage"]); string sortOrder = !String.IsNullOrWhiteSpace(Request.QueryString["sortOrder"]) ? Request.QueryString["sortOrder"] : "DESC"; string sortColumn = !String.IsNullOrWhiteSpace(Request.QueryString["sortColumn"]) ? Request.QueryString["sortColumn"] : "LegalEntityPK"; string ordering = sortColumn + " " + sortOrder; ordering = ordering.Trim(); IQueryable <LegalEntityView> legalEntities = LegalEntityView.GetLegalEntityView(legalEntitiesRepository.GetValid(), legalEntityBranchesRepository.GetValid(), contractsRepository.GetValid(), banksRepository.GetValid(), legalEntitiesBanksRepository.GetValid(), legalEntityLegalRepresentativesRepository.GetValid(), legalEntityOwnersRepository.GetValid(), assessmentsRepository.GetValid()) .OrderBy(ordering); if (!String.IsNullOrWhiteSpace(Request.QueryString["searchString"])) { string searchString = Request.QueryString["searchString"]; legalEntities = legalEntities.Where(c => c.Name.Contains(searchString)); } if (!String.IsNullOrWhiteSpace(Request.QueryString["company"]) && Request.QueryString["company"].Contains("true")) { legalEntities = legalEntities.Where(c => c.Company == true); } if (String.IsNullOrWhiteSpace(Request.QueryString["active"])) { legalEntities = legalEntities.Where(c => c.Active == true); } else { var active = Request.QueryString["active"].Contains("true"); legalEntities = legalEntities.Where(c => c.Active == active); } ViewData["numberOfRecords"] = legalEntities.Count(); legalEntities = legalEntities.Page(page, pageSize); int numberOfPages = ((int)ViewData["numberOfRecords"] + pageSize - 1) / pageSize; if (page > numberOfPages) { string url = LinkHelper.getQueryStringArray(new string[] { "page" }); return(Redirect("LegalEntity?" + url + "page=" + numberOfPages)); } else { return(View("Index", legalEntities.ToList())); } }
public ActionResult Edit(AssessmentsView assessmentView, FormCollection form) { if (ModelState.IsValid) { IAssessmentsRepository assessmentsRepository = new AssessmentsRepository(db); Assessment assessment = assessmentsRepository.GetAssessmentByPK((int)assessmentView.AssessmentPK); IAssessmentAnswersRepository assessmentAnswersRepository = new AssessmentAnswersRepository(db); // Delete old values assessmentAnswersRepository.Delete(a => a.AssessmentFK == assessment.AssessmentPK); // Add new values IAssessmentGroupsRepository assessmentGroupsRepository = new AssessmentGroupsRepository(db); IAssessmentQuestionsRepository assessmentQuestionsRepository = new AssessmentQuestionsRepository(db); IAssessmentTypesRepository assessmentTypesRepository = new AssessmentTypesRepository(db); assessmentView.AssessmentsTypesView = AssessmentsView.FillQuiz(assessmentTypesRepository.GetValid(), assessmentGroupsRepository, assessmentQuestionsRepository, form); // Fetching answered type AssessmentsTypeView atw = assessmentView.AssessmentsTypesView.Where(a => a.AssessmentType.AssessmentTypePK == assessmentView.AssessmentTypeFK).First(); List <AssessmentAnswers> assessmentAnswers = AssessmentAnswerView.ExtractQuizAnswers(atw, assessment.AssessmentPK); ILegalEntitiesRepository legalEntitiesRepository = new LegalEntitiesRepository(db); LegalEntity legalEntity = legalEntitiesRepository.GetLegalEntityByPK((int)assessmentView.LegalEntityFK); bool activityHighRisky = legalEntity.Activity.HighRisk != null && (bool)legalEntity.Activity.HighRisk ? true : false; bool activityLowRisky = legalEntity.Activity.LowRisk != null && (bool)legalEntity.Activity.LowRisk ? true : false; bool headquarterCountryRisky = legalEntity.Country.Risk != null && (bool)legalEntity.Country.Risk ? true : false; IRisksRepository risksRepository = new RisksRepository(db); if (activityHighRisky || headquarterCountryRisky) // check explicitly if related legalEntity activity is high risk { assessmentView.RiskFK = risksRepository.GetRiskByName("Visok").RiskPK; } else if (activityLowRisky) // check explicitly if related legalEntity activity is low risk { assessmentView.RiskFK = risksRepository.GetRiskByName("Nizak").RiskPK; } else // run assesment quiz { ILegalEntityOwnersRepository legalEntityOwnersRepository = new LegalEntityOwnersRepository(db); IQueryable <LegalEntityOwner> legalEntityOwnersTable = legalEntityOwnersRepository.GetValid(); ICountriesRepository countriesRepository = new CountriesRepository(db); IActivitiesRepository activitiesRepository = new ActivitiesRepository(db); List <LegalEntityOwner> coList = legalEntityOwnersRepository.GetFirstLegalEntityOwnersForLegalEntity((int)assessmentView.LegalEntityFK).ToList(); legalEntityOwnersTable = LegalEntityOwnerView.GetLegalEntityOwnersForLegalEntity(Convert.ToInt32(assessmentView.LegalEntityFK), coList, legalEntityOwnersTable); IQueryable <LegalEntity> legalEntityView = LegalEntityOwnerView.GetRelatedLegalEntities(legalEntityOwnersTable, legalEntitiesRepository.GetValid(), countriesRepository.GetValid(), activitiesRepository.GetValid()); // check owners risks bool ownersResidenceCountryRisky = false; bool ownersActivitiesHighlyRisky = false; bool ownersActivitiesLowRisky = false; if (legalEntityView.Count() > 0) { if (legalEntityView.ToList().TrueForAll(le => le.Country.Risk == null || (le.Country.Risk != null && (bool)le.Country.Risk != true)) == false) { ownersResidenceCountryRisky = true; } if (legalEntityView.ToList().TrueForAll(le => le.Activity == null || (le.Activity.HighRisk == null || (le.Activity.HighRisk != null && (bool)le.Activity.HighRisk != true))) == false) { ownersActivitiesHighlyRisky = true; } if (legalEntityView.ToList().TrueForAll(le => le.Activity == null || (le.Activity.LowRisk == null || (le.Activity.LowRisk != null && (bool)le.Activity.LowRisk != true))) == false) { ownersActivitiesLowRisky = true; } } // check form bool allAnswersYes = false; bool allAnswersNo = false; bool mixedAnswers = false; if (assessmentAnswers.TrueForAll(aa => aa.AssessmentAnswer != null && (bool)aa.AssessmentAnswer == true)) { allAnswersYes = true; } if (assessmentAnswers.TrueForAll(aa => aa.AssessmentAnswer != null && (bool)aa.AssessmentAnswer == false)) { allAnswersNo = true; } if (allAnswersYes == false && allAnswersNo == false) { mixedAnswers = true; } // check general conditions if (ownersActivitiesLowRisky) { assessmentView.RiskFK = risksRepository.GetRiskByName("Nizak").RiskPK; } else if (allAnswersYes || ownersResidenceCountryRisky || ownersActivitiesHighlyRisky) { assessmentView.RiskFK = risksRepository.GetRiskByName("Visok").RiskPK; } else if (allAnswersNo || mixedAnswers) { assessmentView.RiskFK = risksRepository.GetRiskByName("Srednji").RiskPK; } } if (assessmentAnswers.Count() > 0) { assessmentAnswersRepository.AddAll(assessmentAnswers); assessmentAnswersRepository.SaveChanges(); } assessmentView.ConvertTo(assessmentView, assessment); assessmentsRepository.SaveChanges(); TempData["message"] = LayoutHelper.GetMessage("UPDATE", assessment.AssessmentPK); return(RedirectToAction("Index", "Assessment")); } else { IAssessmentGroupsRepository assessmentGroupsRepository = new AssessmentGroupsRepository(db); IAssessmentQuestionsRepository assessmentQuestionsRepository = new AssessmentQuestionsRepository(db); //Assessment types ddl IAssessmentTypesRepository assessmentTypesRepository = new AssessmentTypesRepository(db); assessmentView.AssessmentTypes = new SelectList(assessmentTypesRepository.GetValid().OrderBy("Name ASC").ToList(), "AssessmentTypePK", "Name"); //legalEntities ddl ILegalEntitiesRepository legalEntitiesRepository = new LegalEntitiesRepository(db); assessmentView.LegalEntities = new SelectList(legalEntitiesRepository.GetValidLegalEntities().ToList(), "LegalEntityPK", "Name"); assessmentView.AssessmentsTypesView = AssessmentsView.FillQuiz(assessmentTypesRepository.GetValid(), assessmentGroupsRepository, assessmentQuestionsRepository, form); return(View(assessmentView)); } }