コード例 #1
0
 /// <summary>
 /// gets the current line up clock for the game.
 /// </summary>
 /// <param name="id"></param>
 /// <param name="game"></param>
 /// <returns></returns>
 public  static GameStopwatch getLineUpClock(Guid id, GameViewModel game)
 {
     try
     {
         ManagementContext db = new ManagementContext();
         var getClock = (from xx in db.GameStopWatch
                         where xx.StopwatchForId == id
                         where xx.Type == (int)StopWatchTypeEnum.LineUpClock
                         select xx).FirstOrDefault();
         if (getClock != null)
         {
             game.CurrentLineUpClock = new StopwatchWrapper();
             game.CurrentLineUpClock.IsClockAtZero = getClock.IsClockAtZero == 1 ? true : false;
             game.CurrentLineUpClock.IsRunning = getClock.IsRunning == 1 ? true : false;
             game.CurrentLineUpClock.StartTime = getClock.StartDateTime;
             game.CurrentLineUpClock.TimeElapsed = getClock.TimeElapsed;
             game.CurrentLineUpClock.TimeRemaining = getClock.TimeRemaining;
             game.CurrentLineUpClock.TimerLength = getClock.Length;
         }
         return getClock;
     }
     catch (Exception exception)
     {
         ErrorDatabaseManager.AddException(exception, exception.GetType());
     }
     return null;
 }
コード例 #2
0
        public static int insertAssistIntoDb(Guid teamId, GameViewModel game, AssistViewModel assisted, ManagementContext db, DataModels.Game.Game g)
        {
            int c = 0;
            try
            {
                GameMemberAssist assist = new GameMemberAssist();
                assist.DateTimeAssisted = assisted.CurrentDateTimeAssisted;
                assist.GameAssistId = assisted.AssistId;
                assist.JamNumber = assisted.JamNumber;
                assist.JamId = assisted.JamId;
                assist.PeriodNumber = assisted.Period;
                assist.PeriodTimeRemainingMilliseconds = assisted.PeriodTimeRemaining;
                assist.Game = g;

                assist.MemberWhoAssisted = g.GameTeams.Where(x => x.TeamId == teamId).First().GameMembers.Where(x => x.GameMemberId == assisted.PlayerWhoAssisted.SkaterId).FirstOrDefault();
                if (assist.MemberWhoAssisted != null)
                {
                    db.GameMemberAssist.Add(assist);
                    c += db.SaveChanges();
                }
            }
            catch (Exception exception)
            {
                ErrorDatabaseManager.AddException(exception, exception.GetType());
            }
            return c;
        }
コード例 #3
0
        public static void CommitFeedback(string feedback, string league, string email, FeedbackTypeEnum type)
        {
            try
            {

                ManagementContext db = new ManagementContext();

                ScoreboardFeedback fb = new ScoreboardFeedback();
                fb.Created = DateTime.UtcNow;
                fb.Feedback = feedback;
                fb.League = league;
                fb.Email = email;
                fb.FeedbackTypeEnum = (byte)FeedbackTypeEnum.None;
                db.ScoreboardFeedback.Add(fb);
                db.SaveChanges();

                string body = "New Feedback Boss:<br/><br/>";
                body += feedback + "<br/><br/>";
                body += "from: " + email + "<br/>";
                body += "url: http://raspberry.rdnation.com/Admin/Feedback<br/>";
                body += "You Da Man!";


                var emailData = new Dictionary<string, string> { { "body", body } };
                EmailServer.EmailServer.SendEmail(ServerConfig.DEFAULT_EMAIL, ServerConfig.DEFAULT_EMAIL_FROM_NAME, ServerConfig.DEFAULT_INFO_EMAIL, EmailServer.EmailServer.DEFAULT_SUBJECT + " New Feedback", emailData, layout: EmailServerLayoutsEnum.Blank, priority: EmailPriority.Normal);
            }
            catch (Exception exception)
            {
                ErrorDatabaseManager.AddException(exception, exception.GetType());
            }
        }
コード例 #4
0
 public static bool DeleteFolderFromLeague(Guid leagueId, long folderId)
 {
     try
     {
         var dc = new ManagementContext();
         var fold = dc.LeagueDocumentFolders.Where(x => x.League.LeagueId == leagueId && x.CategoryId == folderId).FirstOrDefault();
         if (fold != null)
         {
             fold.ParentFolder = null;
             var docs = dc.LeagueDocuments.Where(x => x.Category.CategoryId == folderId);
             foreach (var doc in docs)
             {
                 doc.Category = null;
             }
             dc.LeagueDocumentFolders.Remove(fold);
             int c = dc.SaveChanges();
             return c > 0;
         }
     }
     catch (Exception exception)
     {
         ErrorDatabaseManager.AddException(exception, exception.GetType());
     }
     return false;
 }
コード例 #5
0
        /// <summary>
        /// This method will add new Forum Message like.
        /// Add if it is new entry.Otherwise it will update the Total Count Column.
        /// </summary>
        /// <param name="MessageId">long MessageId</param>
        /// <param name="memberId">Guid memberId</param>
        /// <returns></returns>
        public static ForumMessage ToggleMessageLike(long MessageId, Guid memberId)
        {
            try
            {
                long total;
                var dc = new ManagementContext();
                var check = dc.ForumMessageLike.Where(x => x.Messages.MessageId == MessageId && x.Member.MemberId == memberId).FirstOrDefault();
                if (check != null)
                {
                    if (check.TotalCount == 0)
                        check.TotalCount = 1;
                    else if (check.TotalCount == 1)
                        check.TotalCount = 0;
                }
                else
                {
                    DataModels.Controls.Forum.ForumMessageLike messageLike = new DataModels.Controls.Forum.ForumMessageLike();
                    messageLike.Member = dc.Members.Where(x => x.MemberId == memberId).FirstOrDefault();
                    messageLike.Messages = dc.ForumMessages.Where(x => x.MessageId == MessageId).FirstOrDefault();
                    messageLike.TotalCount = 1;
                    dc.ForumMessageLike.Add(messageLike);
                }
                int c = dc.SaveChanges();
                total = dc.ForumMessageLike.Where(x => x.Messages.MessageId == MessageId).Sum(x => x.TotalCount);

                if (c > 0)
                    return new ForumMessage { MessageId = MessageId, MessageLikeCount = total };
            }
            catch (Exception exception)
            {
                ErrorDatabaseManager.AddException(exception, exception.GetType());
            }
            return new ForumMessage { MessageId = MessageId, MessageAgreeCount = 0 };
        }
コード例 #6
0
        public static bool ChangeClassificationForMember(Guid duesManagementId, long classificationId, Guid memberId)
        {
            FeeClassificationFactory fClass = new FeeClassificationFactory();
            try
            {
                var dc = new ManagementContext();
                var classy = dc.FeeClassificationByMember.Where(x => x.FeeItem.FeeItem.FeeManagementId == duesManagementId && x.Member.MemberId == memberId).FirstOrDefault();
                if (classificationId == 0)
                {
                    dc.FeeClassificationByMember.Remove(classy);
                }
                else if (classy == null)
                {
                    FeesClassificationByMember m = new FeesClassificationByMember();
                    var classification = dc.FeeClassification.Where(x => x.FeeItem.FeeManagementId == duesManagementId && x.FeeClassificationId == classificationId).FirstOrDefault();

                    m.FeeItem = classification;
                    m.Member = dc.Members.Where(x => x.MemberId == memberId).FirstOrDefault();
                    classification.MembersClassified.Add(m);
                    dc.FeeClassificationByMember.Add(m);
                }
                else
                {
                    classy.FeeItem = dc.FeeClassification.Where(x => x.FeeItem.FeeManagementId == duesManagementId && x.FeeClassificationId == classificationId).FirstOrDefault();
                }
                int c = dc.SaveChanges();
                return c > 0;
            }
            catch (Exception exception)
            {
                ErrorDatabaseManager.AddException(exception, exception.GetType());
            }
            return false;
        }
コード例 #7
0
        public static bool Add_New_List(RDN.Library.Classes.League.TaskList.TaskListDA NewTaskList)
        {

            try
            {
                var dc = new ManagementContext();
                DataModels.League.Task.TaskList con = new DataModels.League.Task.TaskList();
                con.AssignedTo = NewTaskList.AssignedTo;
                con.EndDate = NewTaskList.EndDate;
                con.ListAddByMember = dc.Members.Where(x => x.MemberId == NewTaskList.ListAddByMember).FirstOrDefault();
                con.ListName = NewTaskList.ListName;
                con.TaskListForLeague = dc.Leagues.Where(x => x.LeagueId == NewTaskList.TaskListForLeague).FirstOrDefault();

                dc.TaskLists.Add(con);

                int c = dc.SaveChanges();

                return c > 0;

            }
            catch (Exception exception)
            {
                ErrorDatabaseManager.AddException(exception, exception.GetType());

            }
            return false;
        }
コード例 #8
0
        public static List<ColorDisplay> GetLeagueColors(Guid leagueId)
        {
            try
            {
                var dc = new ManagementContext();

                var colors = (from xx in dc.LeagueColors
                              where xx.League.LeagueId == leagueId
                              select new ColorDisplay
                              {
                                  ColorId = xx.ColorId,
                                  CSharpColor = xx.Color.ColorIdCSharp,
                                  NameOfColor = xx.Color.ColorName
                              }).OrderBy(x => x.CSharpColor).ToList();
                foreach (var color in colors)
                {
                    Color c = System.Drawing.Color.FromArgb(color.CSharpColor);
                    color.HexColor = ColorTranslator.ToHtml(c);

                }
                return colors;
            }
            catch (Exception exception)
            {
                ErrorDatabaseManager.AddException(exception, exception.GetType());
            }
            return new List<ColorDisplay>();
        }
コード例 #9
0
        public static int DoUpdates()
        {
            try
            {
                int c = 0;
                var dc = new ManagementContext();
                var mems = dc.LeagueMembers.Where(x => x.LeagueOwnersEnum > 0);
                foreach (var mem in mems)
                {
                    mem.LeagueOwnersEnums = (int)mem.LeagueOwnersEnum;
                    if (mem.LeagueOwnersEnum > 0)
                        Console.WriteLine(mem.LeagueOwnersEnum);
                    //leagueMember.LeagueOwnersEnums = (int)owner;
                    mem.League = mem.League;
                    mem.Member = mem.Member;

                }
                c += dc.SaveChanges();


                return c;
            }
            catch (Exception exception)
            {
                ErrorDatabaseManager.AddException(exception, exception.GetType());
            }
            return 0;
        }
コード例 #10
0
        public static void insertBlockIntoDb(Guid teamId, GameViewModel game, BlockViewModel block, ManagementContext db, DataModels.Game.Game g)
        {
            try
            {
                GameMemberBlock blocks = new GameMemberBlock();
                blocks.DateTimeBlocked = block.CurrentDateTimeBlock;
                blocks.GameBlockId = block.BlockId;
                blocks.JamNumber = block.JamNumber;
                blocks.JamId = block.JamId;
                blocks.PeriodNumber = block.Period;
                blocks.PeriodTimeRemainingMilliseconds = block.PeriodTimeRemaining;
                blocks.Game = g;

                blocks.MemberWhoBlocked = g.GameTeams.Where(x => x.TeamId == teamId).First().GameMembers.Where(x => x.GameMemberId == block.PlayerWhoBlocked.SkaterId).FirstOrDefault();
                if (blocks.MemberWhoBlocked != null)
                {
                    db.GameMemberBlock.Add(blocks);
                    db.SaveChanges();
                }
            }
            catch (Exception exception)
            {
                ErrorDatabaseManager.AddException(exception, exception.GetType());
            }
        }
コード例 #11
0
        public static bool AddColor(string nameOfColor, string colorHex)
        {
            try
            {
                var dc = new ManagementContext();
                Color color = ColorTranslator.FromHtml(colorHex);
                int arb = color.ToArgb();
                var colorDb = dc.Colors.Where(x => x.ColorIdCSharp == arb).FirstOrDefault();

                if (colorDb == null)
                {
                    DataModels.Color.Color co = new DataModels.Color.Color();
                    co.ColorName = nameOfColor;
                    co.ColorIdCSharp = arb;
                    dc.Colors.Add(co);
                    int c = dc.SaveChanges();
                    return c > 0;
                }
                return true;
            }
            catch (Exception exception)
            {
                ErrorDatabaseManager.AddException(exception, exception.GetType(), additionalInformation: nameOfColor + " " + colorHex);
            }
            return false;
        }
コード例 #12
0
ファイル: Team.cs プロジェクト: mukhtiarlander/git_demo_torit
        /// <summary>
        /// gets all the logos in the DB.
        /// </summary>
        /// <returns></returns>
        public List<RDN.Portable.Classes.Team.TeamLogo> GetAllLogos(TeamDisplay team)
        {
            try
            {
                if (team.LeagueLogos == null || team.LeagueLogos.Count == 0)
                {
                    var dc = new ManagementContext();
                    if (team.ScoreboardLogos == null || team.ScoreboardLogos.Count == 0)
                        team.ScoreboardLogos = GetAllScoreboardLogos(team);

                    var leagues = dc.Leagues.Where(x => x.Logo != null).AsParallel().ToList();
                    foreach (var league in leagues)
                    {
                        RDN.Portable.Classes.Team.TeamLogo logo = new RDN.Portable.Classes.Team.TeamLogo();
                        logo.ImageUrl = league.Logo.ImageUrl;
                        logo.TeamName = league.Name;
                        logo.TeamLogoId = league.Logo.LeaguePhotoId;
                        team.LeagueLogos.Add(logo);
                    }
                    team.LeagueLogos = team.LeagueLogos.OrderBy(x => x.TeamName).ToList();
                }
                return team.LeagueLogos;
            }
            catch (Exception e)
            {
                Library.Classes.Error.ErrorDatabaseManager.AddException(e, e.GetType(), ErrorGroupEnum.Database);
            }
            return null;
        }
コード例 #13
0
ファイル: Team.cs プロジェクト: mukhtiarlander/git_demo_torit
        public List<RDN.Portable.Classes.Team.TeamLogo> GetAllScoreboardLogos(TeamDisplay team)
        {
            try
            {
                if (team.ScoreboardLogos == null)
                {
                    var dc = new ManagementContext();
                    var logos = dc.TeamLogos.AsParallel().OrderBy(x => x.TeamName).ToList();
                    for (int i = 0; i < logos.Count; i++)
                    {
                        team.ScoreboardLogos.Add(new RDN.Portable.Classes.Team.TeamLogo()
                        {
                            Height = logos[i].Height.ToString(),
                            ImageUrl = logos[i].ImageUrl,
                            ImageUrlThumb = logos[i].ImageUrlThumb,
                            SaveLocation = logos[i].SaveLocation,
                            TeamLogoId = logos[i].TeamLogoId,
                            TeamName = logos[i].TeamName,
                            Width = logos[i].Width.ToString()

                        });
                    }
                }

                return team.ScoreboardLogos;
            }
            catch (Exception e)
            {
                Library.Classes.Error.ErrorDatabaseManager.AddException(e, e.GetType(), ErrorGroupEnum.Database);
            }
            return null;
        }
コード例 #14
0
 public static LeagueBilling GetCurrentBillingStatus(Guid leagueId)
 {
     LeagueBilling bi = new LeagueBilling();
     try
     {
         var dc = new ManagementContext();
         PaymentGateway pg = new PaymentGateway();
         var invoice = pg.GetLatestInvoiceSubscriptionForLeagueId(leagueId);
         
         bi.LeagueId = leagueId;
         bi.LeagueName = dc.Leagues.Where(x => x.LeagueId == leagueId).Select(x => x.Name).FirstOrDefault();
         if (invoice != null)
         {
             bi.InvoiceId = invoice.InvoiceId;
             bi.Expires = invoice.Subscription.ValidUntil;
             bi.LastBilledOn = invoice.Subscription.Created;
             bi.MembershipStatus = CurrentStatusOfBillingEnum.League_Membership;
             bi.PaymentProviderCustomerId = invoice.PaymentProviderCustomerId;
         }
         else
         {
             bi.MembershipStatus = CurrentStatusOfBillingEnum.None;
         }
     }
     catch (Exception exception)
     {
         ErrorDatabaseManager.AddException(exception, exception.GetType());
     }
     return bi;
 }
コード例 #15
0
        public static bool RemoveDuesCollectionItem(long duesItemId, Guid duesManagementId, Guid memId, long duesCollectedId)
        {
            try
            {
                var dc = new ManagementContext();
                var item = (from xx in dc.FeesCollected
                            where xx.MemberPaid.MemberId == memId
                            where xx.FeeItem.FeeCollectionId == duesItemId
                            where xx.FeeItem.FeeManagedBy.FeeManagementId == duesManagementId
                            select xx);

                foreach (var fee in item)
                {
                    fee.IsPaidInFull = false;
                }
                var feed = item.Where(x => x.FeeCollectionId == duesCollectedId).FirstOrDefault();
                if (feed != null)
                    dc.FeesCollected.Remove(feed);

                int c = dc.SaveChanges();
                return true;
            }
            catch (Exception exception)
            {
                ErrorDatabaseManager.AddException(exception, exception.GetType());
            }
            return false;
        }
コード例 #16
0
 /// <summary>
 /// updates the penalty box DB with new information
 /// </summary>
 /// <param name="game"></param>
 /// <param name="cachedGame"></param>
 /// <param name="db"></param>
 /// <param name="pen"></param>
 public static void updatePenaltyBoxInDb(GameViewModel game, ManagementContext db, SkaterInPenaltyBoxViewModel pen, DataModels.Game.Game g)
 {
     try
     {
         var cachedPen = g.GameMemberPenaltyBox.Where(x => x.PenaltyIdFromGame == pen.PenaltyId).FirstOrDefault();
         if (cachedPen == null)
             insertNewPenaltyIntoDb(game, db, pen, g);
         else
         {
             cachedPen.GameTimeMilliSecondsReturned = pen.GameTimeInMillisecondsReleased;
             cachedPen.GameTimeMilliSecondsSent = pen.GameTimeInMillisecondsSent;
             cachedPen.JamNumberReturned = pen.JamNumberReleased;
             cachedPen.JamNumberSent = pen.JamNumberSent;
             cachedPen.JamIdReturned = pen.JamIdReleased;
             cachedPen.JamIdSent = pen.JamIdSent;
             cachedPen.JamTimeMilliSecondsReturned = pen.JamTimeInMillisecondsReleased;
             cachedPen.JamTimeMilliSecondsSent = pen.JamTimeInMillisecondsSent;
             cachedPen.PenaltyType = pen.PenaltyType.ToString();
             db.SaveChanges();
         }
     }
     catch (Exception exception)
     {
         ErrorDatabaseManager.AddException(exception, exception.GetType());
     }
 }
コード例 #17
0
        /// <summary>
        /// Gets a list with merchants for overview
        /// </summary>
        /// <returns></returns>
        public List<OverviewMerchant> GetMerchants()
        {
            var output = new List<OverviewMerchant>();
            try
            {
                var mc = new ManagementContext();
                var merchants = mc.Merchants.Include("Items").Where(x => x.IsRDNation.Equals(false)).Select(x => new { x.MerchantId, x.InternalReference, x.PrivateManagerId, x.InternalReferenceType, x.OwnerName, x.ShopName, x.AmountOnAccount, x.PayedFeesToRDN, x.Created, itemsInShop = x.Items.Count });

                foreach (var dbmerchant in merchants)
                {
                    var merchant = new OverviewMerchant();
                    merchant.AmountOnAccount = dbmerchant.AmountOnAccount;
                    merchant.PrivateManagerId = dbmerchant.PrivateManagerId;
                    merchant.Created = dbmerchant.Created;
                    merchant.InternalReference = dbmerchant.InternalReference;
                    merchant.InternalReferenceType = (MerchantInternalReference)dbmerchant.InternalReferenceType;
                    merchant.MerchantId = dbmerchant.MerchantId;
                    merchant.OwnerName = dbmerchant.OwnerName;
                    merchant.PayedFeesToRDN = dbmerchant.PayedFeesToRDN;
                    merchant.ShopName = dbmerchant.ShopName;
                    merchant.NumberOfItemsForSale = dbmerchant.itemsInShop;
                    output.Add(merchant);
                }
            }
            catch (Exception exception)
            {
                ErrorDatabaseManager.AddException(exception, exception.GetType());
            }
            return output;
        }
コード例 #18
0
 public static void insertNewPenaltyIntoDb(GameViewModel game, ManagementContext db, SkaterInPenaltyBoxViewModel pen, DataModels.Game.Game g)
 {
     try
     {
         var m = GameMemberClass.getMemberOfTeamInGame(pen.PlayerSentToBox.SkaterId, g);
         if (m != null)
         {
             GameMemberPenaltyBox penalty = new GameMemberPenaltyBox();
             penalty.PenaltyNumberForSkater = pen.PenaltyNumberForSkater;
             penalty.Member = m;
             penalty.GameTimeMilliSecondsSent = pen.GameTimeInMillisecondsSent;
             penalty.GameTimeMilliSecondsReturned = pen.GameTimeInMillisecondsReleased;
             penalty.JamNumberReturned = pen.JamNumberReleased;
             penalty.JamIdReturned = pen.JamIdReleased;
             penalty.JamIdSent = pen.JamIdSent;
             penalty.JamTimeMilliSecondsReturned = pen.JamTimeInMillisecondsReleased;
             penalty.JamTimeMilliSecondsSent = pen.JamTimeInMillisecondsSent;
             penalty.Game = g;
             penalty.PenaltyIdFromGame = pen.PenaltyId;
             penalty.PenaltyType = pen.PenaltyType.ToString();
             db.GameMemberPenaltyBox.Add(penalty);
             db.SaveChanges();
         }
     }
     catch (Exception exception)
     {
         ErrorDatabaseManager.AddException(exception, exception.GetType());
     }
 }
コード例 #19
0
        /// <summary>
        /// Adds a Node to the Site Map
        /// </summary>
        /// <param name="url">URL to add to SiteMap</param>
        /// <param name="modified">true oo false if the item has just been modified.</param>
        public static void AddNode(string url, bool modified)
        {
            var dc = new ManagementContext();
            var site = dc.SiteMap.Where(x => x.Url.ToLower() == url.ToLower()).FirstOrDefault();
            if (site == null)
            {
                Sitemap siteMap = new Sitemap();
                siteMap.ChangeFrequency = Convert.ToInt32(SitemapHelperEnum.monthly);
                siteMap.LastModified = DateTime.UtcNow;
                siteMap.Url = url.ToLower();
                dc.SiteMap.Add(siteMap);
                dc.SaveChanges();
            }
            else
            {
                if (modified)
                {
                    site.LastModified = DateTime.UtcNow;

                    TimeSpan span = DateTime.UtcNow.Subtract(site.LastModified.Value);
                    if (span.Days > 365)
                        site.ChangeFrequency = Convert.ToInt32(SitemapHelperEnum.yearly);
                    else if (span.Days > 31)
                        site.ChangeFrequency = Convert.ToInt32(SitemapHelperEnum.monthly);
                    else if (span.Days > 7)
                        site.ChangeFrequency = Convert.ToInt32(SitemapHelperEnum.weekly);
                    else if (span.Hours > 24)
                        site.ChangeFrequency = Convert.ToInt32(SitemapHelperEnum.daily);
                    else
                        site.ChangeFrequency = Convert.ToInt32(SitemapHelperEnum.hourly);
                    dc.SaveChanges();
                }
            }

        }
コード例 #20
0
        public static BruiseBash GetBruiseBashItem(Guid idOfBruise)
        {
            try
            {
                var dc = new ManagementContext();
                var bruise = dc.BruiseBashItem.Where(x => x.BruiseBashId == idOfBruise).FirstOrDefault();

                BruiseBash bashObject = new BruiseBash();
                bashObject.Story = bruise.Story;
                bashObject.Title = bruise.Title;
                bashObject.File = bruise.Image.ImageUrl;
                bashObject.BruiseId = bruise.BruiseBashId;

                foreach (var comment in bruise.Comments)
                {
                    BruiseBashComment comTemp = new BruiseBashComment();
                    comTemp.Comment = comment.Comment;
                    comTemp.CommentId = comment.CommentId;
                    comTemp.Created = comment.Created;
                    if (comment.Owner != null)
                        comTemp.OwnerId = comment.Owner.MemberId;
                    bashObject.Comments.Add(comTemp);
                }
                foreach (var rating in bruise.Ratings)
                {
                    BruiseBashRatings ratTemp = new BruiseBashRatings();
                    ratTemp.Created = rating.Created;
                    if (rating.Rater != null)
                        ratTemp.RaterId = rating.Rater.MemberId;
                    ratTemp.RatingId = rating.RatingId;

                    if (rating.Loser != null)
                    {
                        BruiseBash loserBash = new BruiseBash();
                        loserBash.Story = rating.Loser.Story;
                        loserBash.Title = rating.Loser.Title;
                        loserBash.File = rating.Loser.Image.ImageUrl;
                        loserBash.BruiseId = rating.Loser.BruiseBashId;
                        ratTemp.Loser = loserBash;
                    }

                    if (rating.Winner != null)
                    {
                        BruiseBash winnerBash = new BruiseBash();
                        winnerBash.Story = rating.Winner.Story;
                        winnerBash.Title = rating.Winner.Title;
                        winnerBash.File = rating.Winner.Image.ImageUrl;
                        winnerBash.BruiseId = rating.Winner.BruiseBashId;
                        ratTemp.Winner = winnerBash;
                    }
                    bashObject.Ratings.Add(ratTemp);
                }
                return bashObject;
            }
            catch (Exception exception)
            {
                ErrorDatabaseManager.AddException(exception, exception.GetType());
            }
            return null;
        }
コード例 #21
0
        public static void UpdateLocations()
        {
            var dc = new ManagementContext();
            var adds = dc.Addresses;
            foreach (var add in adds)
            {
                try
                {
                    var coords = OpenStreetMap.FindLatLongOfAddress(add.Address1, add.Address2, add.Zip, add.CityRaw, add.StateRaw, add.Country != null ? add.Country.Name : String.Empty);
                    if (coords != null)
                    {
                        add.Coords = new System.Device.Location.GeoCoordinate();
                        add.Coords.Latitude = coords.Latitude;
                        add.Coords.Longitude = coords.Longitude;
                        add.Coords.Altitude = 0;
                        add.Coords.Course = 0;
                        add.Coords.HorizontalAccuracy = 1;
                        add.Coords.Speed = 0;
                        add.Coords.VerticalAccuracy = 1;
                    }
                    add.ContactCard = add.ContactCard;


                }
                catch (Exception exception)
                {
                    ErrorDatabaseManager.AddException(exception, exception.GetType());
                }
            }
            dc.SaveChanges();

        }
コード例 #22
0
 public static int DeepCompareOfficialReviewsToDb(GameViewModel game, ManagementContext db, DataModels.Game.Game gameNew)
 {
     try
     {
         if (game.OfficialReviews != null)
         {
             foreach (var member in game.OfficialReviews)
             {
                 var review = gameNew.OfficialReviews.Where(x => x.OfficialReviewIdFromGame == member.OfficialReviewId).FirstOrDefault();
                 if (review == null)
                     AddOfficialReview(game, gameNew, member);
                 else
                 {
                     review.TeamNumber = (byte)member.TeamNumber;
                     review.Details = member.Details;
                     review.Result = member.Result;
                 }
             }
         }
     }
     catch (Exception exception)
     {
         ErrorDatabaseManager.AddException(exception, exception.GetType());
     }
     return db.SaveChanges();
 }
コード例 #23
0
        public static bool EditLeagueContact(Guid leagueId, ContactDisplayBasic contact)
        {
            try
            {
                var dc = new ManagementContext();
                var con = dc.LeagueContacts.Where(x => x.Contact.ContactId == contact.ContactId).FirstOrDefault();

                con.Contact.CompanyName = contact.CompanyName;
                con.Contact.Firstname = contact.FirstName;
                con.Contact.Lastname = contact.LastName;
                con.Contact.Link = contact.Link;

                int countryId = Convert.ToInt32(contact.CountryId);
                ContactCard.ContactCardFactory.UpdateAddressToContact(contact.Address1, contact.Address2, contact.CityRaw, contact.StateRaw, contact.Zip, AddressTypeEnum.None, con.Contact.ContactCard, dc.Countries.Where(x => x.CountryId == countryId).FirstOrDefault());
                ContactCard.ContactCardFactory.UpdatePhoneNumberToCard(contact.PhoneNumber, con.Contact.ContactCard, String.Empty);
                ContactCard.ContactCardFactory.UpdateEmailToContactCard(contact.Email, con.Contact.ContactCard);
                
                con.Notes = contact.Notes;
                con.ContactTypeEnum = (byte)((ContactTypeForOrganizationEnum)Enum.Parse(typeof(ContactTypeForOrganizationEnum), contact.ContactTypeSelected));
                con.League = con.League;
                con.Contact = con.Contact;
                int c = dc.SaveChanges();
                return c > 0;
            }
            catch (Exception exception)
            {
                ErrorDatabaseManager.AddException(exception, exception.GetType());
            }
            return false;
        }
コード例 #24
0
 public static void insertScoreIntoDb(Guid teamId, GameViewModel game, ScoreViewModel score, ManagementContext db, DataModels.Game.Game g)
 {
     try
     {
         GameScore scores = new GameScore();
         if (score.CurrentDateTimeScored != new DateTime())
             scores.DateTimeScored = score.CurrentDateTimeScored;
         else
             scores.DateTimeScored = DateTime.UtcNow;
         scores.GameScoreId = score.PointId;
         scores.JamNumber = score.JamNumber;
         scores.JamId = score.JamId;
         scores.PeriodNumber = score.Period;
         scores.PeriodTimeRemainingMilliseconds = score.PeriodTimeRemaining;
         scores.Point = score.Points;
         scores.GameTeam = g.GameTeams.Where(x => x.TeamId == teamId).First();
         if (score.PlayerWhoScored != null && score.PlayerWhoScored.SkaterId != new Guid())
             scores.MemberWhoScored = g.GameTeams.Where(x => x.TeamId == teamId).First().GameMembers.Where(x => x.GameMemberId == score.PlayerWhoScored.SkaterId).FirstOrDefault();
         db.GameScore.Add(scores);
         db.SaveChanges();
     }
     catch (Exception exception)
     {
         ErrorDatabaseManager.AddException(exception, exception.GetType(), additionalInformation: "jamId:" + score.JamId + "/ pointId:" + score.PointId);
     }
 }
コード例 #25
0
        public static bool Add_New_Task(RDN.Library.Classes.League.TaskList.TaskDA NewTask)
        {

            try
            {
                var dc = new ManagementContext();
                DataModels.League.Task.Task con = new DataModels.League.Task.Task();
                con.Completed = NewTask.Completed;
                con.Title = NewTask.Title;
                con.DeadLine = NewTask.DeadLine;
                con.EndDate = NewTask.EndDate;
                con.Notes = NewTask.Notes;
                con.StartDate = NewTask.StartDate;
                con.StatusId = NewTask.StatusId;
                con.TaskAddByMember = dc.Members.Where(x => x.MemberId == NewTask.TaskAddByMember).FirstOrDefault();
                con.TaskBelongsTo = dc.TaskLists.Where(x => x.ListId == NewTask.TaskListId).FirstOrDefault();
                

                dc.Tasks.Add(con);

                int c = dc.SaveChanges();

                return c > 0;

            }
            catch (Exception exception)
            {
                ErrorDatabaseManager.AddException(exception, exception.GetType());

            }
            return false;
        }
コード例 #26
0
        public bool UpdateMerchantSettings(OverviewMerchant store)
        {
            try
            {
                var dc = new ManagementContext();
                var merc = dc.Merchants.Where(x => x.InternalReference == store.InternalReference && x.MerchantId == store.MerchantId && x.PrivateManagerId == store.PrivateManagerId).FirstOrDefault();

                if (merc != null)
                {
                    merc.OrderPayedNotificationEmail = store.OrderPayedNotificationEmail;
                    merc.PaypalEmail = store.PaypalEmail;
                    //need to make sure we have a paypal email.
                    if (String.IsNullOrEmpty(merc.PaypalEmail))
                        merc.AcceptPaymentsViaPaypal = false;
                    else
                        merc.AcceptPaymentsViaPaypal = store.AcceptPaymentsViaPaypal;
                    if (merc.AcceptPaymentsViaStripe || (store.AcceptPaymentsViaPaypal && !String.IsNullOrEmpty(store.PaypalEmail)))
                        merc.IsPublished = store.IsPublished;
                    else
                        merc.IsPublished = false;

                    dc.SaveChanges();
                    return true;
                }
            }
            catch (Exception exception)
            {
                ErrorDatabaseManager.AddException(exception, exception.GetType());
            }
            return false;
        }
コード例 #27
0
        public static bool Add_New_Sponsor(RDN.Library.Classes.League.Sponsor NewSponsor)
        {

            try
            {
                var dc = new ManagementContext();
                DataModels.League.Sponsorship con = new DataModels.League.Sponsorship();
                con.Description = NewSponsor.Description;
                con.PromoCode = NewSponsor.PromoCode;
                con.SponsorName = NewSponsor.SponsorName;
                con.Website = NewSponsor.Website;
                if (NewSponsor.BeginDate != new DateTime())
                    con.BeginDate = NewSponsor.BeginDate;
                if (NewSponsor.EndDate != new DateTime())
                    con.EndDate = NewSponsor.EndDate;
                con.Sponsored = NewSponsor.Sponsored;

                con.SponsorForLeague = dc.Leagues.Where(x => x.LeagueId == NewSponsor.SponsorForLeague).FirstOrDefault();
                con.SponsorAddByMember = dc.Members.Where(x => x.MemberId == NewSponsor.SponsorAddByMember).FirstOrDefault();
                dc.Sponsorships.Add(con);

                int c = dc.SaveChanges();

                return c > 0;

            }
            catch (Exception exception)
            {
                ErrorDatabaseManager.AddException(exception, exception.GetType(), additionalInformation: NewSponsor.EndDate + ":" + NewSponsor.BeginDate);

            }
            return false;
        }
コード例 #28
0
        public static void PullClassifications(Guid duesManagementId)
        {
            try
            {
                var dc = new ManagementContext();
                var clas = (from xx in dc.FeeManagement
                            where xx.FeeManagementId == duesManagementId
                            select new
                            {
                                xx.FeeClassifications,
                                xx.LeagueOwner.Members
                            }).FirstOrDefault();

                for (int i = 0; i < clas.Members.Count; i++)
                {

                }


            }
            catch (Exception exception)
            {
                ErrorDatabaseManager.AddException(exception, exception.GetType());
            }
        }
コード例 #29
0
        public static bool Add_New_Item(RDN.Library.Classes.League.ItemInfoDA NewItem)
        {

            try
            {
                var dc = new ManagementContext();
                DataModels.League.ItemInfo con = new DataModels.League.ItemInfo();
                con.ItemSerialNo = NewItem.ItemSerialNo;
                con.ItemName = NewItem.ItemName;
                con.Location = NewItem.Location;
                con.Notes = NewItem.Notes;
                con.Quantity = NewItem.Quantity;
                con.UnitePice = NewItem.UnitePice;

                con.ItemsForLeague = dc.Leagues.Where(x => x.LeagueId == NewItem.ItemsForLeague).FirstOrDefault();
                con.ItemAddByMember = dc.Members.Where(x => x.MemberId == NewItem.ItemAddByMember).FirstOrDefault();
                dc.ItemInfos.Add(con);

                int c = dc.SaveChanges();

                return c > 0;

            }
            catch (Exception exception)
            {
                ErrorDatabaseManager.AddException(exception, exception.GetType());

            }
            return false;
        }
コード例 #30
0
        public static void MoveOwnersOfGameOverToNewOwnershipSystem()
        {
            var dc = new ManagementContext();
            var gameDb = (from xx in dc.Games
                          select xx).ToList();

            foreach (var game in gameDb)
            {
                if (game.OwnerOfGame != null)
                {
                    GameMemberOwnership owner = new GameMemberOwnership();
                    owner.Game = game;
                    owner.Member = game.OwnerOfGame;
                    owner.OwnerType = Convert.ToInt32(GameOwnerEnum.Owner);
                    game.MemberOwners.Add(owner);
                }
                if (game.FederationOwner != null)
                {
                    GameFederationOwnership owner = new GameFederationOwnership();
                    owner.Game = game;
                    owner.Federation = game.FederationOwner;
                    owner.OwnerType = Convert.ToInt32(GameOwnerEnum.Owner);
                    game.FederationOwners.Add(owner);
                }
            }
            dc.SaveChanges();
        }