private void HandleEasyIdConference(Conference conference) { if (!string.IsNullOrWhiteSpace(conference.ConferenceId)) { return; } if (string.IsNullOrWhiteSpace(conference.ConferenceShort)) { conference.ConferenceId = Guid.NewGuid().ToString(); return; } var easyId = Util.IdGenerator.AsPrimaryKey(conference.ConferenceShort); if (string.IsNullOrWhiteSpace(easyId)) { return; } if (Conferences.All(n => n.ConferenceId != easyId)) { conference.ConferenceId = easyId; } else { conference.ConferenceId = Guid.NewGuid().ToString(); } }
public E3ViewModel() { Conferences.Add(new Conference("EA", DateTime.Now, DateTime.Now.AddMinutes(1))); Conferences.Add(new Conference("Microsoft", DateTime.Now.AddMinutes(2), DateTime.Now.AddMinutes(3))); Conferences.Add(new Conference("Ubisoft", DateTime.Now.AddMinutes(5), DateTime.Now.AddMinutes(6))); Conferences.Add(new Conference("Sony", DateTime.Now.AddMinutes(7), DateTime.Now.AddMinutes(8))); }
void ReCountIdleTimeSpan() { IdleTimeSpans.Clear(); var scheduledConfs = Conferences.OrderBy(x => x.StartTime).ToList(); IdleTimeSpan curTimeSpan = null; for (int i = 0; i <= scheduledConfs.Count; i++) { if (i == 0) { curTimeSpan = new IdleTimeSpan { StartTime = OpenStartTime }; } if (i < scheduledConfs.Count && scheduledConfs[i].StartTime > curTimeSpan.StartTime) { curTimeSpan.EndTime = scheduledConfs[i].StartTime; IdleTimeSpans.Add(curTimeSpan); curTimeSpan = new IdleTimeSpan { StartTime = scheduledConfs[i].EndTime }; } if (i == scheduledConfs.Count && scheduledConfs.LastOrDefault().EndTime < OpenEndTime) { curTimeSpan = new IdleTimeSpan { StartTime = scheduledConfs.LastOrDefault().EndTime, EndTime = OpenEndTime }; } } }
private void initObjectModels() { // initializing footer objects terms = new Terms(browser); privacy = new Privacy(browser); security = new Security(browser); status = new Status(browser); help = new Help(browser); footerLogo = new pageObjectModels.footer.Logo(browser); contactGitHub = new ContactGitHub(browser); api = new API(browser); training = new Training(browser); shop = new Shop(browser); footerBlog = new pageObjectModels.footer.Blog(browser); about = new About(browser); // initializing explore objects integrations = new Integrations(browser); showcases = new Showcases(browser); trending = new Trending(browser); // initializing header objects headerLogo = new pageObjectModels.header.Logo(browser); personal = new Personal(browser); openSource = new OpenSource(browser); business = new Business(browser); explore = new Explore(browser); pricing = new Pricing(browser); headerBlog = new pageObjectModels.header.Blog(browser); support = new Support(browser); searchBar = new pageObjectModels.header.SearchBar(browser); signIn = new SignIn(browser); signUp = new SignUp(browser); // initializing main objects signUpUsername = new SignUpUsername(browser); signUpEmail = new SignUpEmail(browser); signUpPassword = new SignUpPassword(browser); signUpSubmit = new SignUpSubmit(browser); signUpForGitHub = new SignUpForGitHubButton(browser); // initializing pricing objects joinGitHubForFree = new JoinGitHubForFree(browser); upgradeAccount = new UpgradeAccount(browser); createOrganization = new CreateOrganization(browser); startEnterpriseTrial = new StartEnterpriseTrial(browser); // initializing blog objects featured = new Featured(browser); allPosts = new AllPosts(browser); newFeatures = new NewFeatures(browser); engineering = new Engineering(browser); enterprise = new Enterprise(browser); conferences = new Conferences(browser); meetups = new Meetups(browser); newHires = new NewHires(browser); watercooler = new Watercooler(browser); blogSearchBar = new pageObjectModels.blog.SearchBar(browser); }
void Handle_Delete(object param) { if (param != null) { var conference = param as Conference; Conferences.Remove(conference); } }
public ActionResult DeleteConfirmed(string id) { Conferences conferences = db.Conferences.Find(id); db.Conferences.Remove(conferences); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Add() { var conference = new Conferences(); { Date = DateTime.Today; }; return(View(conference)); }
public static void Clear() { Account = null; Username = string.Empty; Conference = null; Roles.Clear(); Conferences.Clear(); Author = null; }
public ConferenceViewModel() { //Определяем контекст данных и связываем с базой данных _db = new DbContextEntityes("name=DbConnectionString"); //Получаем список конференций Conferences = _db.Conferences.ToList(); MinDate = Conferences.OrderBy(w => w.Duration).FirstOrDefault().Duration; MaxDate = Conferences.OrderByDescending(w => w.Duration).FirstOrDefault().Duration; }
private PlayoffSpots getPlayoffSpot(Conferences conference, Divisions division, int?conferenceRank, int?divisionRank) { var playoffSpot = string.Empty; if (divisionRank <= PlayoffRules.LastDivisionRankToGetQualified) { switch (division) { case Divisions.Atlantic: playoffSpot = "A"; break; case Divisions.Metropolitan: playoffSpot = "M"; break; case Divisions.Central: playoffSpot = "C"; break; case Divisions.Pacific: playoffSpot = "P"; break; } playoffSpot += divisionRank; } else if (divisionRank <= PlayoffRules.LastDivisionRankToBeAWildcard && conferenceRank <= PlayoffRules.LastConferenceRankToBeAWildcard) { switch (conference) { case Conferences.Eastern: playoffSpot = "EWC"; break; case Conferences.Westnern: playoffSpot = "WWC"; break; } if (divisionRank <= PlayoffRules.LastDivisionRankToBeFirstWildcard && conferenceRank <= PlayoffRules.LastConferenceRankToBeFirstWildcard) { playoffSpot += "1"; } else { playoffSpot += "2"; } } else { return(PlayoffSpots.Unqualified); } return((PlayoffSpots)Enum.Parse(typeof(PlayoffSpots), playoffSpot)); }
public ScientistAddsConferenceViewModel(ScientistModel selectedScientist) { SelectedScientist = selectedScientist; List <Conference> conferences = ConferenceService.GetConferences(); foreach (Conference c in conferences) { Conferences.Add(new ConferenceModel(c)); } }
public bool Update(Conferences conferences, int old_conferenceId) { ConferencesDAC conferencesComponent = new ConferencesDAC(); SiteLogic siteLogic = new ContentManagement.SiteLogic(); Site site = siteLogic.GetByID(conferences.SiteId); site.Name = conferences.ConferenceName; siteLogic.Update(site, site.SiteId); return(conferencesComponent.UpdateConferences(conferences.SiteId, conferences.ConferenceName, conferences.ConferenceLogo, conferences.StartDate, conferences.EndDate, conferences.IsActive, conferences.Location, conferences.LocationName, conferences.LocationLogo, conferences.LocationLongitude, conferences.LocationLatitude, conferences.ConferenceDomain, conferences.ConferenceCode, conferences.ConferenceAlias, conferences.ConferenceVenueID, conferences.IsDefault, conferences.AbstractSubmissionStartDate, conferences.AbstractSubmissionEndDate, conferences.AbstractSubmissionEndMessagePageID, conferences.AbstractSubmissionNotStartedPageID, old_conferenceId)); }
public ActionResult Add(Conferences conference) { if (ModelState.IsValid) { _conferenceRepository.AddConference(conference); return(RedirectToAction("Upcoming")); } return(View(conference)); }
public ActionResult Edit([Bind(Include = "Id,ChairId,Title,Location,Date,Deadline")] Conferences conferences) { if (ModelState.IsValid) { db.Entry(conferences).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ChairId = new SelectList(db.Chairs, "Id", "Id", conferences.ChairId); return(View(conferences)); }
// GET: Conferences/Details/5 public ActionResult Details(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Conferences conferences = db.Conferences.Find(id); if (conferences == null) { return(HttpNotFound()); } return(View(conferences)); }
public ActionResult Edit(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Conferences conferences = db.Conferences.Find(id); if (conferences == null) { return(HttpNotFound()); } ViewBag.ChairId = new SelectList(db.Chairs, "Id", "Id", conferences.ChairId); return(View(conferences)); }
public Conferences GetConference(int id) { Conferences c = null; foreach (var conference in _conferences) { if (conference.ConferenceId == id) { c = conference; break; } } return(c); }
public Conferences GetCurrentConference(string domain) { Conferences result = null; result = GetConferenceBySubDomain(domain); if (result == null) { result = GetDefaultConference(); } if (result == null) { result = GetByID(1); } return(result); }
public void TestGettingTotalCountOfConferences() { // Arrange // The URI we are using in the test var requestUri = new Uri("https://localhost/api/admin/status/v1/conference/"); ConferenceResponse conferencesModel = new ConferenceResponse { MetaObject = new MetaObject { TotalCount = 15 } }; // Serialise the object var expectedResponse = JsonConvert.SerializeObject(conferencesModel); // Set up the mock with the expected response var mockResponse = new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent(expectedResponse) }; var mockHandler = new Mock <HttpClientHandler>(); mockHandler .Protected() .Setup <Task <HttpResponseMessage> >( "SendAsync", ItExpr.Is <HttpRequestMessage>(message => message.RequestUri == requestUri), ItExpr.IsAny <CancellationToken>()) .Returns(Task.FromResult(mockResponse)); // Set up the HttpClient using the mock handler object HttpClient client = new HttpClient(mockHandler.Object); // Initialise an instance of the Participants class for testing using the HttpClient IConferences conferences = new Conferences(client, "https://localhost"); // Act var conferencesTotalCount = conferences.GetTotal().Result; // Assert Assert.True(conferencesTotalCount == 15); }
public static Schedule Create(Conferences.Conference conference) { var res = new Schedule(conference); var locations = LocationRepository.Instance.GetLocations(conference.ConferenceId).OrderBy(l => l.Sort); var sessions = SessionRepository.Instance.GetSessions(conference.ConferenceId).Where(s => s.Status > 2 && s.SlotId > 0 && s.DayNr > 0); var locationList = new List<Locations.Location>(); foreach (var location in locations) { if (sessions.Where(s => s.LocationId == location.LocationId).Count() > 0) { locationList.Add(location); } } res.Locations = locationList; var slots = SlotRepository.Instance.GetSlots(conference.ConferenceId).OrderBy(s => s.StartMinutes); var nrDays = (conference.EndDate != null ? ((int)((DateTime)conference.EndDate).Subtract((DateTime)conference.StartDate).TotalDays) : 1); for (int dayNr = 0; dayNr < nrDays; dayNr++) { var ds = new DaySchedule(((DateTime)conference.StartDate).AddDays(dayNr).Date, dayNr + 1); var nrSessions = 0; foreach (var slot in slots.Where(s => s.DayNr == dayNr + 1 | s.DayNr == null)) { var ts = new DaySchedule.TimeSlot(slot); if (slot.SlotType == (int)SlotType.Session) { foreach (var session in sessions.Where(s => s.DayNr == dayNr + 1 & s.SlotId == slot.SlotId)) { if (session.LocationId == null) { ts.Sessions.Add(-1, session); } else { ts.Sessions.Add((int)session.LocationId, session); } nrSessions++; } } ds.Slots.Add(slot.StartMinutes, ts); } ds.TotalSessions = nrSessions; res.Days.Add(dayNr, ds); } return res; }
void Handle_Search(string key) { if (key.Length > 4) { var searchItems = Conferences.Where(x => x.Title.ToLower().StartsWith(key.ToLower())).ToList(); Conferences.Clear(); searchItems.ForEach(x => Conferences.Add(x)); Count = searchItems.Count(); } else { if (key.Length == 0) { Conferences.Clear(); BindData(); } } }
public void AddConference(Conferences conference) { // Get the next available entry ID. int nextAvailableEntryId = _conferences.Max(x => x.ConferenceId) + 1; conference.ConferenceId = nextAvailableEntryId; var conferences2 = new Conferences[_conferences.Length + 1]; for (int i = 0; i < _conferences.Length; i++) { conferences2[i] = _conferences[i]; } conferences2[_conferences.Length] = conference; _conferences = conferences2; // Add(conference); }
public bool Insert(Conferences conferences) { int autonumber = 0; ConferencesDAC conferencesComponent = new ConferencesDAC(); SiteLogic siteLogic = new ContentManagement.SiteLogic(); Site site = new Site() { Name = conferences.ConferenceName, IsActive = true }; siteLogic.Insert(site); conferences.SiteId = site.SiteId; bool endedSuccessfuly = conferencesComponent.InsertNewConferences(ref autonumber, conferences.SiteId, conferences.ConferenceName, conferences.ConferenceLogo, conferences.StartDate, conferences.EndDate, conferences.IsActive, conferences.Location, conferences.LocationName, conferences.LocationLogo, conferences.LocationLongitude, conferences.LocationLatitude, conferences.ConferenceDomain, conferences.ConferenceCode, conferences.ConferenceAlias, conferences.ConferenceVenueID, conferences.IsDefault, conferences.AbstractSubmissionStartDate, conferences.AbstractSubmissionEndDate, conferences.AbstractSubmissionEndMessagePageID, conferences.AbstractSubmissionNotStartedPageID); if (endedSuccessfuly) { conferences.ConferenceId = autonumber; } return(endedSuccessfuly); }
public bool CheckConferenceTime(Conference conference) { if (conference.StartTime < OpenStartTime) { return(false); } if (conference.EndTime > OpenEndTime) { return(false); } foreach (var timeSpan in IdleTimeSpans) { if (timeSpan.StartTime <= conference.StartTime && timeSpan.EndTime >= conference.EndTime) { Conferences.Add(conference); ReCountIdleTimeSpan(); return(true); } } return(false); }
public async Task <Conference> GetActiveConference() { return(await Conferences.Where(x => x.Date >= DateTime.Today).OrderBy(x => x.Date).FirstOrDefaultAsync()); }
public Conferences GetByID(int _conferenceId) { ConferencesDAC _conferencesComponent = new ConferencesDAC(); IDataReader reader = _conferencesComponent.GetByIDConferences(_conferenceId); Conferences _conferences = null; while (reader.Read()) { _conferences = new Conferences(); if (reader["ConferenceId"] != DBNull.Value) { _conferences.ConferenceId = Convert.ToInt32(reader["ConferenceId"]); } if (reader["SiteId"] != DBNull.Value) { _conferences.SiteId = Convert.ToInt32(reader["SiteId"]); } if (reader["ConferenceName"] != DBNull.Value) { _conferences.ConferenceName = Convert.ToString(reader["ConferenceName"]); } if (reader["ConferenceLogo"] != DBNull.Value) { _conferences.ConferenceLogo = Convert.ToString(reader["ConferenceLogo"]); } if (reader["StartDate"] != DBNull.Value) { _conferences.StartDate = Convert.ToDateTime(reader["StartDate"]); } if (reader["EndDate"] != DBNull.Value) { _conferences.EndDate = Convert.ToDateTime(reader["EndDate"]); } if (reader["IsActive"] != DBNull.Value) { _conferences.IsActive = Convert.ToBoolean(reader["IsActive"]); } if (reader["Location"] != DBNull.Value) { _conferences.Location = Convert.ToString(reader["Location"]); } if (reader["LocationName"] != DBNull.Value) { _conferences.LocationName = Convert.ToString(reader["LocationName"]); } if (reader["LocationLogo"] != DBNull.Value) { _conferences.LocationLogo = Convert.ToString(reader["LocationLogo"]); } if (reader["LocationLongitude"] != DBNull.Value) { _conferences.LocationLongitude = Convert.ToDecimal(reader["LocationLongitude"]); } if (reader["LocationLatitude"] != DBNull.Value) { _conferences.LocationLatitude = Convert.ToDecimal(reader["LocationLatitude"]); } if (reader["ConferenceDomain"] != DBNull.Value) { _conferences.ConferenceDomain = Convert.ToString(reader["ConferenceDomain"]); } if (reader["ConferenceCode"] != DBNull.Value) { _conferences.ConferenceCode = Convert.ToString(reader["ConferenceCode"]); } if (reader["ConferenceVenueID"] != DBNull.Value) { _conferences.ConferenceVenueID = Convert.ToInt32(reader["ConferenceVenueID"]); } if (reader["ConferenceAlias"] != DBNull.Value) { _conferences.ConferenceAlias = Convert.ToString(reader["ConferenceAlias"]); } if (reader["IsDefault"] != DBNull.Value) { _conferences.IsDefault = Convert.ToBoolean(reader["IsDefault"]); } if (reader["AbstractSubmissionStartDate"] != DBNull.Value) { _conferences.AbstractSubmissionStartDate = Convert.ToDateTime(reader["AbstractSubmissionStartDate"]); } if (reader["AbstractSubmissionEndDate"] != DBNull.Value) { _conferences.AbstractSubmissionEndDate = Convert.ToDateTime(reader["AbstractSubmissionEndDate"]); } if (reader["AbstractSubmissionEndMessagePageID"] != DBNull.Value) { _conferences.AbstractSubmissionEndMessagePageID = Convert.ToInt32(reader["AbstractSubmissionEndMessagePageID"]); } if (reader["AbstractSubmissionNotStartedPageID"] != DBNull.Value) { _conferences.AbstractSubmissionNotStartedPageID = Convert.ToInt32(reader["AbstractSubmissionNotStartedPageID"]); } _conferences.NewRecord = false; } reader.Close(); return(_conferences); }
private static void Add(Conferences conference) { throw new NotImplementedException(); }
//Using http://app.cgy.nhl.yinzcam.com/V2/Stats/Standings public void PopulateNHLTeams() { XmlTextReader reader = new XmlTextReader("http://app.cgy.nhl.yinzcam.com/V2/Stats/Standings"); var nhlTeams = new List <NHLTeam>(); string fullName = string.Empty; int? conferenceRank = null; int? divisionRank = null; PlayoffSpots playoffSpot = PlayoffSpots.Unqualified; Conferences conference = Conferences.Undefined; Divisions division = Divisions.Undefined; while (reader.Read()) { //Conference if (reader.Name.Equals("Conference")) { reader.MoveToAttribute("Name"); if (reader.Value.Equals("WESTERN")) { conference = Conferences.Westnern; } else { conference = Conferences.Eastern; } } //Division if (reader.Name.Equals("StatsSection")) { reader.MoveToAttribute("Heading"); switch (reader.Value) { case "PACIFIC": division = Divisions.Pacific; break; case "CENTRAL": division = Divisions.Central; break; case "ATLANTIC": division = Divisions.Atlantic; break; case "METROPOLITAN": default: division = Divisions.Metropolitan; break; } } //Team if (reader.Name.Equals("Standing")) { reader.MoveToAttribute("Team"); fullName = reader.Value; if (!fullName.Equals(string.Empty)) { reader.MoveToAttribute("ConfRank"); int _conferenceRank; if (int.TryParse(reader.Value, out _conferenceRank)) { conferenceRank = _conferenceRank; } reader.MoveToAttribute("DivRank"); int _divisionRank; if (int.TryParse(reader.Value, out _divisionRank)) { divisionRank = _divisionRank; } playoffSpot = getPlayoffSpot(conference, division, conferenceRank, divisionRank); poolManagerDbContext.NHLTeams.Add( new NHLTeam { FullName = fullName, Conference = conference, Division = division, PlayoffSpot = playoffSpot } ); } } } poolManagerDbContext.SaveChanges(); }
public Schedule(Conferences.Conference conference) { Conference = conference; Days = new Dictionary<int, DaySchedule>(); }
protected override DbEntityValidationResult ValidateEntity(DbEntityEntry entityEntry, IDictionary <object, object> items) { List <DbValidationError> errors = new List <DbValidationError>(); if (entityEntry.Entity is Conference && (entityEntry.State == EntityState.Added || entityEntry.State == EntityState.Modified)) { var conference = (Conference)entityEntry.Entity; if (conference.StartDate.CompareTo(conference.EndDate) >= 0) { errors.Add(new DbValidationError("EndDate", String.Format("The end date must be after start date ({0})", conference.StartDate))); } if (Conferences.Any(c => c.Id != conference.Id && (conference.EndDate.CompareTo(c.StartDate) >= 0 && conference.StartDate.CompareTo(c.EndDate) <= 0))) { errors.Add(new DbValidationError("StartDate", String.Format("The conference '{0}' time must not interfere with those existent", conference.Name))); } if (conference.Name == "") { errors.Add(new DbValidationError("Name", "Conference name can't be null")); } if (conference.Domain == "") { errors.Add(new DbValidationError("Domain", "Conference domain can't be null")); } if (conference.MainDescription == "") { errors.Add(new DbValidationError("Main Description", "Conference description can't be null")); } if (conference.AbstractDeadline.CompareTo(conference.StartDate) >= 0) { errors.Add(new DbValidationError("AbstractDeadline", String.Format("The deadline for abstracts submission must be before {0}", conference.StartDate))); } if (conference.FullPaperDeadline.CompareTo(conference.StartDate) >= 0) { errors.Add(new DbValidationError("FullPapersDeadline", String.Format("The deadline for full papers submission must be before {0}", conference.StartDate))); } if (errors.Count > 0) { return(new DbEntityValidationResult(entityEntry, errors)); } } else if (entityEntry.Entity is Proposal && (entityEntry.State == EntityState.Added || entityEntry.State == EntityState.Modified)) { var proposal = (Proposal)entityEntry.Entity; if (proposal.Title == "") { errors.Add(new DbValidationError("Title", "Proposal title can't be null")); } if (proposal.Subject == "") { errors.Add(new DbValidationError("Subject", "Proposal subject can't be null")); } if (proposal.Abstract == "") { errors.Add(new DbValidationError("Abstract", "Proposal abstract can't be null")); } if (proposal.Keywords == "") { errors.Add(new DbValidationError("Keywords", "Proposal keywords can't be null")); } if ((proposal.ProposalState != ProposalState.Accepted) && (proposal.ProposalState != ProposalState.Declined) && (proposal.ProposalState != ProposalState.Pending)) { errors.Add(new DbValidationError("ProposalState", "ProposalState must be Accepted, Declined or Pending")); } if (errors.Count > 0) { return(new DbEntityValidationResult(entityEntry, errors)); } } else if (entityEntry.Entity is Review && (entityEntry.State == EntityState.Added || entityEntry.State == EntityState.Modified)) { var review = (Review)entityEntry.Entity; if (review.Recommendation == "") { errors.Add(new DbValidationError("Recommendation", "Review recommendation can't be null")); } if ((review.Mark != Mark.StrongAccept) && (review.Mark != Mark.Accept) && (review.Mark != Mark.WeakAccept) && (review.Mark != Mark.BorderlinePaper) && (review.Mark != Mark.WeakReject) && (review.Mark != Mark.Reject) && (review.Mark != Mark.StrongReject)) { errors.Add(new DbValidationError("Mark", "Mark must be StrongAccept, Accept, WeakAccept, BordelinePaper, WeakReject, Reject or StrongReject")); } if (errors.Count > 0) { return(new DbEntityValidationResult(entityEntry, errors)); } } else if (entityEntry.Entity is User_Conference && (entityEntry.State == EntityState.Added || entityEntry.State == EntityState.Modified)) { var userconf = (User_Conference)entityEntry.Entity; if ((userconf.Role != UserRole.Chair) && (userconf.Role != UserRole.CoChair) && (userconf.Role != UserRole.Listener) && (userconf.Role != UserRole.Speaker) && (userconf.Role != UserRole.Reviewer)) { errors.Add(new DbValidationError("Role", "Role must be Chair, CoChair, Listener, Speaker or Reviewer")); } if (errors.Count > 0) { return(new DbEntityValidationResult(entityEntry, errors)); } } else if (entityEntry.Entity is Section && (entityEntry.State == EntityState.Added || entityEntry.State == EntityState.Modified)) { var section = (Section)entityEntry.Entity; if (section.Title == "") { errors.Add(new DbValidationError("Title", "Section title can't be null")); } if (section.StartDate.CompareTo(section.EndDate) >= 0) { errors.Add(new DbValidationError("EndDate", String.Format("The end date must be after start date ({0})", section.StartDate))); } var conference = Conferences.FirstOrDefault(c => c.Id == section.ConferenceId); if (section.StartDate.CompareTo(conference.StartDate) < 0 || section.StartDate.CompareTo(conference.EndDate) > 0) { errors.Add(new DbValidationError("Start Date", String.Format("The section must begin after the conference start date"))); } if (section.EndDate.CompareTo(conference.EndDate) > 0) { errors.Add(new DbValidationError("End Date", String.Format("The section must end before the conference end date"))); } if (errors.Count > 0) { return(new DbEntityValidationResult(entityEntry, errors)); } } else if (entityEntry.Entity is User && (entityEntry.State == EntityState.Added || entityEntry.State == EntityState.Modified)) { var user = (User)entityEntry.Entity; if (user.Username == "" || user.Username == null) { errors.Add(new DbValidationError("Username", "Username can't be null")); } if (user.Password == "" || user.Password == null) { errors.Add(new DbValidationError("Password", "Password can't be null")); } if (user.FirstName == null || user.FirstName == "") { errors.Add(new DbValidationError("FirstName", "Firstname can't be null")); } if (user.LastName == null || user.LastName == "") { errors.Add(new DbValidationError("Lastname", "Lastname can't be null")); } if (user.Email == "" || user.Email == null) { errors.Add(new DbValidationError("Email", "This email is not valid")); } else { var addr = new System.Net.Mail.MailAddress(user.Email); if (addr.Address != user.Email) { errors.Add(new DbValidationError("Email", "This email is not valid")); } } if (user.WebPage == "" || user.WebPage == null) { errors.Add(new DbValidationError("Webpage", "Webpage can't be null")); } if (errors.Count > 0) { return(new DbEntityValidationResult(entityEntry, errors)); } } return(base.ValidateEntity(entityEntry, items)); }
public ScientistModel(Scientist scientist, bool downloadEntityDates = true) { Scientist = scientist; if (downloadEntityDates) { List <Conference> conferences = ScientistService.GetConferences(Scientist); foreach (Conference c in conferences) { Conferences.Add(new ConferenceModel(c, false)); } foreach (Report r in Scientist.Reports) { Reports.Add(new ReportModel(r)); } List <Organization> organizations = ScientistService.GetOrganizations(Scientist); foreach (Organization o in organizations) { Organizations.Add(new OrganizationModel(o, false)); } } Conferences.CollectionChanged += (o, e) => { if (e.Action.ToString().Equals("Add")) { ConferenceModel cm = null; foreach (ConferenceModel cmo in e.NewItems) { cm = cmo; } ScientistService.AddConference(Scientist, cm.Conference); } else if (e.Action.ToString().Equals("Remove")) { ConferenceModel cm = null; foreach (ConferenceModel cmo in e.OldItems) { cm = cmo; } ScientistService.RemoveConference(Scientist, cm.Conference); } OnPropertyChanged("Conferences"); }; Reports.CollectionChanged += (o, e) => { if (e.Action.ToString().Equals("Add")) { ReportModel rm = null; foreach (ReportModel rem in e.NewItems) { rm = rem; } ScientistService.AddReport(Scientist, rm.Report); } else if (e.Action.ToString().Equals("Remove")) { ReportModel rm = null; foreach (ReportModel rem in e.OldItems) { rm = rem; } ScientistService.RemoveReport(Scientist, rm.Report); } OnPropertyChanged("Reports"); OnPropertyChanged("ReportsCount"); }; Organizations.CollectionChanged += (o, e) => { if (e.Action.ToString().Equals("Add")) { OrganizationModel om = null; foreach (OrganizationModel orm in e.NewItems) { om = orm; } ScientistService.AddOrganization(Scientist, om.Organization); } else if (e.Action.ToString().Equals("Remove")) { OrganizationModel om = null; foreach (OrganizationModel orm in e.OldItems) { om = orm; } ScientistService.RemoveOrganization(Scientist, om.Organization); } OnPropertyChanged("Organizations"); }; }