protected void RegisterDomain(object o, EventArgs e) { Domain d = new Domain(); d.DomainName = DomainName; if (!d.IsAvailable) { ErrorMessage = d.DomainName + " already exists!"; return; } d.PromoterK = PromoterK; if (uiOptionsList.SelectedPanelID == uiBrandDiv.ClientID) { d.RedirectApp = BrandRedirectApp; d.RedirectObjectK = BrandK; d.RedirectObjectType = Model.Entities.ObjectType.Brand; } else if (uiOptionsList.SelectedPanelID == uiVenueDiv.ClientID) { d.RedirectApp = VenueRedirectApp; d.RedirectObjectK = VenueK; d.RedirectObjectType = Model.Entities.ObjectType.Venue; } else if (uiOptionsList.SelectedPanelID == uiEventDiv.ClientID) { Event ev = new Event(EventK); if (!ev.IsPromoter(PromoterK)) throw new Exception("This event isn't in this promoter account!"); d.RedirectObjectK = EventK; d.RedirectObjectType = Model.Entities.ObjectType.Event; } else if (uiOptionsList.SelectedPanelID == uiGroupDiv.ClientID) { Group gr = new Group(GroupK); d.RedirectObjectK = GroupK; d.RedirectObjectType = Model.Entities.ObjectType.Group; } else { d.RedirectUrl = CustomUrl; } d.Update(); d.Register(); AddedDomain = d; SetStage(Stage.TestRedirect); }
public void PanelEdit_Save(object o, System.EventArgs e) { EnsureSecure(); if (Page.IsValid) { Comp c = null; if (Mode.Equals(Modes.Add)) { c = new Comp(); c.DateTimeAdded = DateTime.Now; c.PromoterK = CurrentPromoter.K; c.Status = Comp.StatusEnum.New; } else if (Mode.Equals(Modes.Edit)) { c = CurrentComp; } c.DisplayType = Comp.DisplayTypes.New; c.DateTimeStart = EditDateStart.SelectedDate; c.DateTimeClose = new DateTime(EditDateClose.SelectedDate.Year, EditDateClose.SelectedDate.Month, EditDateClose.SelectedDate.Day, 12, 0, 0); c.Question = Cambro.Web.Helpers.StripHtml(EditQuestion.Text.Trim()).Truncate(200); c.Answer1 = Cambro.Web.Helpers.StripHtml(EditAnswer1.Text.Trim()).Truncate(100); c.Answer2 = Cambro.Web.Helpers.StripHtml(EditAnswer2.Text.Trim()).Truncate(100); c.Answer3 = Cambro.Web.Helpers.StripHtml(EditAnswer3.Text.Trim()).Truncate(100); c.CorrectAnswer = EditCorrectRadio1.Checked ? 1 : (EditCorrectRadio2.Checked ? 2 : 3); c.Prize = Cambro.Web.Helpers.StripHtml(EditPrizesFirstDesc.Text.Trim()).Truncate(200); c.Prize2 = Cambro.Web.Helpers.StripHtml(EditPrizesSecondDesc.Text.Trim()).Truncate(200); c.Prize3 = Cambro.Web.Helpers.StripHtml(EditPrizesThirdDesc.Text.Trim()).Truncate(200); c.SponsorDetails = EditSponsorDescriptionHtml.GetHtml(); try { c.Winners = int.Parse(EditPrizesFirstNumber.Text.Trim()); } catch { throw new DsiUserFriendlyException("Number of first prizes must be a number"); } try { c.Winners2 = EditPrizesSecondNumber.Text.Trim().Equals("") ? 0 : int.Parse(EditPrizesSecondNumber.Text.Trim()); } catch { throw new DsiUserFriendlyException("Number of second prizes must be a number or blank"); } try { c.Winners3 = EditPrizesThirdNumber.Text.Trim().Equals("") ? 0 : int.Parse(EditPrizesThirdNumber.Text.Trim()); } catch { throw new DsiUserFriendlyException("Number of third prizes must be a number or blank"); } Usr u; try { u = new Usr(int.Parse(EditPrizeContact.SelectedValue)); } catch { throw new DsiUserFriendlyException("Prize contact not valid!"); } if (!u.IsEnabledPromoter(CurrentPromoter.K)) throw new DsiUserFriendlyException("Prize contact not valid!"); c.OwnerUsrK = u.K; try { c.PrizeValueRange = int.Parse(EditPrizesValue.SelectedValue); } catch { throw new DsiUserFriendlyException("Prize value not valid!"); } if (CurrentEvent != null) { c.LinkType = Comp.LinkTypes.Event; c.BrandK = 0; c.EventK = CurrentEvent.K; } else if (EditLinkNoneRadio.Checked) { c.LinkType = Comp.LinkTypes.None; c.BrandK = 0; c.EventK = 0; } else if (EditLinkEventRadio.Checked) { c.LinkType = Comp.LinkTypes.Event; c.BrandK = 0; if (UpcomingEvents.Count == 1) c.EventK = UpcomingEvents[0].K; else { Event ev; try { ev = new Event(int.Parse(EditLinkEventDropDown.SelectedValue)); } catch { throw new DsiUserFriendlyException("Can't use this event!"); } if (!ev.IsPromoter(CurrentPromoter.K)) throw new DsiUserFriendlyException("Can't use this event!"); c.EventK = ev.K; } } else if (EditLinkBrandRadio.Checked) { c.LinkType = Comp.LinkTypes.Brand; c.EventK = 0; c.BrandK = 0; if (CurrentPromoter.AllBrands.Count == 1) c.BrandK = CurrentPromoter.AllBrands[0].K; else { Brand b; try { b = new Brand(int.Parse(EditLinkBrandDropDown.SelectedValue)); } catch { throw new DsiUserFriendlyException("Can't use this brand!"); } if (b.PromoterK != CurrentPromoter.K) throw new DsiUserFriendlyException("Can't use this brand!"); c.BrandK = b.K; } } c.Update(); if (c.HasPic) RedirectDone(); else Response.Redirect(ContainerPage.Url.CurrentUrl("mode", "pic", "compk", c.K.ToString())); } }