protected UltimateDC.Agency GetAgency() { if (_agency == null) { UltimateDataContext dc = new UltimateDataContext(); int agencyId = 0; if (Int32.TryParse(Request.QueryString["agencyid"], out agencyId)) { bool isAdmin = User.IsInRole("Administrators"); _agency = (from p in dc.Agencies where p.Id == agencyId && (isAdmin || p.PlaceberryUser.aspnet_User.UserName == User.Identity.Name) select p).SingleOrDefault(); } if (_agency == null) { //Ne postoji ili trenutni korisnik nema prava Response.Redirect("/manage/customer.aspx"); } } return _agency; }
public static bool CheckAgencyExists(string agency) { bool exists = false; agency = agency == null ? string.Empty : agency.Trim().ToLower(); using (UltimateDataContext dc = new UltimateDataContext()) { exists = dc.Agencies.Any(i => i.Name.ToLower() == agency); } return exists; }
private void FetchAgency() { string agencyTag = Common.FixQueryStringUrlTag(Request.QueryString["agencytag"] ?? string.Empty); agency = (from p in dc.AgencyUrlTags where p.UrlTag == agencyTag select p.Agency).SingleOrDefault(); if (agency == null) { //Ne postoji Response.Redirect("/", true); } }
private void FetchAgency() { int agencyId = 0; int.TryParse(Request["agencyId"] == null ? string.Empty : Request["agencyId"], out agencyId); bool admin = User.IsInRole("Administrators"); agency = (from p in dc.Agencies where p.Id == agencyId && (admin || p.PlaceberryUser.aspnet_User.UserName == User.Identity.Name) select p).SingleOrDefault(); if (agency == null) { //Ne postoji ili trenutni korisnik nema prava Response.Redirect("/manage/customer.aspx"); } aBackToAgency.HRef = String.Format("/manage/Agency.aspx?agencyid={0}", agency.Id); }
protected void NewAgency() { mvwContainer.ActiveViewIndex = 1; hAgency.InnerText = "Unos agencije"; imgLogoE.Visible = false; agency = new UltimateDC.Agency(); agency.ManagerId = (Guid)Membership.GetUser().ProviderUserKey; dc.Agencies.InsertOnSubmit(agency); btnSave.CommandName = "new"; if (!IsPostBack) ddlLanguage.SelectedValue = Common.GetLanguageId().ToString(); }