public static List <LegalEntityLegalRepresentativeAuditView> GetLegalEntityLegalRepresentativeAuditView(ObjectContext context, int relatedEntityPK) { IAuditingDetailsRepository auditingDetailsRepository = new AuditingDetailsRepository(context); IAuditingMasterRepository auditingMasterRepository = new AuditingMasterRepository(context); var sessionTokens = (from am in auditingMasterRepository.GetAll().Where(c => c.TableName == "LegalEntityLegalRepresentatives") where am.RelatedEntityPK == relatedEntityPK select new { AuditingMasterPK = am.AuditingMasterPK, RelatedEntityPK = am.RelatedEntityPK, SessionToken = am.SessionToken }).ToList(); List <LegalEntityLegalRepresentativeAuditView> legalEntityLegalRepresentativeAuditViewList = new List <LegalEntityLegalRepresentativeAuditView>(); foreach (var item in sessionTokens) { var record = auditingDetailsRepository.GetAuditingDetailByAuditingMasterPK(item.AuditingMasterPK).ToList(); LegalEntityLegalRepresentativeAuditView legalEntityLegalRepresentativeAuditView = new LegalEntityLegalRepresentativeAuditView(); legalEntityLegalRepresentativeAuditView.LegalEntityFK = record.checkInteger("LegalEntityFK"); legalEntityLegalRepresentativeAuditView.LegalRepresentativeFK = record.checkInteger("LegalRepresentativeFK"); legalEntityLegalRepresentativeAuditView.WayOfRepresentationFK = record.checkInteger("WayOfRepresentationFK"); legalEntityLegalRepresentativeAuditView.ChangeDate = record.checkDate("ChangeDate"); legalEntityLegalRepresentativeAuditView.Deleted = record.checkBoolean("Deleted"); legalEntityLegalRepresentativeAuditViewList.Add(legalEntityLegalRepresentativeAuditView); } IPhysicalEntitiesRepository physicalEntitiesRepository = new PhysicalEntitiesRepository(context); IQueryable <PhysicalEntity> physicalEntityTable = physicalEntitiesRepository.GetValid(); IWaysOfRepresentationRepository WaysOfRepresentationRepository = new WaysOfRepresentationRepository(context); IQueryable <WayOfRepresentation> wayOfRepresentationTable = WaysOfRepresentationRepository.GetValid(); List <LegalEntityLegalRepresentativeAuditView> legalEntityLegalRepresentative = (from t in legalEntityLegalRepresentativeAuditViewList from t1 in physicalEntityTable.Where(tbl => tbl.PhysicalEntityPK == t.LegalRepresentativeFK).DefaultIfEmpty() from t2 in wayOfRepresentationTable.Where(tbl => tbl.WayOfRepresentationPK == t.WayOfRepresentationFK).DefaultIfEmpty() where t.ChangeDate != null select new LegalEntityLegalRepresentativeAuditView { LegalEntityLegalRepresentativePK = t.LegalEntityLegalRepresentativePK, LegalRepresentativeName = t1 != null && t1.Firstname != null && t1.Lastname != null ? t1.Firstname + " " + t1.Lastname : null, WayOfRepresentationName = t2 != null && t2.Name != null ? t2.Name : null, ChangeDate = t.ChangeDate != null ? t.ChangeDate : null, Deleted = t.Deleted != null ? t.Deleted : null, }).OrderBy(c => c.ChangeDate).ToList(); return(legalEntityLegalRepresentative); }
public void BindDDLs(LegalEntityLegalRepresentativeView legalEntityLegalRepresentativeView, ObjectContext db) { //way of representation ddl IWaysOfRepresentationRepository wayOfRepresentationView = new WaysOfRepresentationRepository(db); legalEntityLegalRepresentativeView.WaysOfRepresentation = new SelectList(wayOfRepresentationView.GetValid().OrderBy("Name ASC").ToList(), "WayOfRepresentationPK", "Name"); //physicalEntity ddl PhysicalEntityView PhysicalEntityView = new PhysicalEntityView(); IPhysicalEntitiesRepository physicalEntitiesRepository = new PhysicalEntitiesRepository(db); legalEntityLegalRepresentativeView.LegalRepresentatives = new SelectList(PhysicalEntityView.GetPhysicalEntitySelect(physicalEntitiesRepository.GetValid()).ToList(), "PhysicalEntityPK", "Name"); }
public ActionResult Delete(int?wayOfRepresentationPK) { IWaysOfRepresentationRepository waysOfRepresentationRepository = new WaysOfRepresentationRepository(db); if (wayOfRepresentationPK != null) { WayOfRepresentation wayOfRepresentation = waysOfRepresentationRepository.GetWayOfRepresentationByPK((int)wayOfRepresentationPK); wayOfRepresentation.Deleted = true; waysOfRepresentationRepository.SaveChanges(); TempData["message"] = LayoutHelper.GetMessage("DELETE", wayOfRepresentation.WayOfRepresentationPK); } return(Redirect(Request.UrlReferrer.AbsoluteUri)); }
public ActionResult Edit(int?wayOfRepresentationPK) { if (wayOfRepresentationPK != null) { IWaysOfRepresentationRepository waysOfRepresentationRepository = new WaysOfRepresentationRepository(db); WayOfRepresentation wayOfRepresentation = waysOfRepresentationRepository.GetWayOfRepresentationByPK((int)wayOfRepresentationPK); WayOfRepresentationView wayOfRepresentationView = new WayOfRepresentationView(); wayOfRepresentationView.ConvertFrom(wayOfRepresentation, wayOfRepresentationView); return(View(wayOfRepresentationView)); } else { return(RedirectToAction("Index", "WayOfRepresentation")); } }
public ActionResult Index() { IWaysOfRepresentationRepository waysOfRepresentationRepository = new WaysOfRepresentationRepository(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"] : "WayOfRepresentationPK"; string ordering = sortColumn + " " + sortOrder; ordering = ordering.Trim(); IQueryable <WayOfRepresentation> waysOfRepresentation = waysOfRepresentationRepository.GetValid() .OrderBy(ordering); if (!String.IsNullOrWhiteSpace(Request.QueryString["searchString"])) { string searchString = Request.QueryString["searchString"].ToString(); waysOfRepresentation = waysOfRepresentation.Where(c => c.Name.Contains(searchString)); } waysOfRepresentation = waysOfRepresentation.Page(page, pageSize); if (!String.IsNullOrWhiteSpace(Request.QueryString["searchString"])) { string searchString = Request.QueryString["searchString"].ToString(); ViewData["numberOfRecords"] = waysOfRepresentationRepository.GetValid().Where(c => c.Name.Contains(searchString)).Count(); } else { ViewData["numberOfRecords"] = waysOfRepresentationRepository.GetValid().Count(); } int numberOfPages = ((int)ViewData["numberOfRecords"] + pageSize - 1) / pageSize; if (page > numberOfPages) { string url = LinkHelper.getQueryStringArray(new string[] { "page" }); return(Redirect("WayOfRepresentation?" + url + "page=" + numberOfPages)); } else { return(View("Index", waysOfRepresentation.ToList())); } }
public ActionResult Edit(WayOfRepresentationView wayOfRepresentationModel) { if (ModelState.IsValid) { IWaysOfRepresentationRepository waysOfRepresentationRepository = new WaysOfRepresentationRepository(db); WayOfRepresentation wayOfRepresentation = waysOfRepresentationRepository.GetWayOfRepresentationByPK((int)wayOfRepresentationModel.WayOfRepresentationPK); wayOfRepresentationModel.ConvertTo(wayOfRepresentationModel, wayOfRepresentation); waysOfRepresentationRepository.SaveChanges(); TempData["message"] = LayoutHelper.GetMessage("UPDATE", wayOfRepresentation.WayOfRepresentationPK); return(RedirectToAction("Index", "WayOfRepresentation")); } else { return(View(wayOfRepresentationModel)); } }
public ActionResult Add(WayOfRepresentationView wayOfRepresentationView) { if (ModelState.IsValid) { IWaysOfRepresentationRepository waysOfRepresentationRepository = new WaysOfRepresentationRepository(db); WayOfRepresentation wayOfRepresentation = new WayOfRepresentation(); wayOfRepresentationView.ConvertTo(wayOfRepresentationView, wayOfRepresentation); waysOfRepresentationRepository.Add(wayOfRepresentation); waysOfRepresentationRepository.SaveChanges(); TempData["message"] = LayoutHelper.GetMessage("INSERT", wayOfRepresentation.WayOfRepresentationPK); return(RedirectToAction("Index", "WayOfRepresentation")); } else { return(View(wayOfRepresentationView)); } }