Ejemplo n.º 1
0
 public static Apply_record GetApplyRecord(int recordId)
 {
     using (var context = new DataModels())
     {
         return(context.Apply_record.Find(recordId));
     }
 }
Ejemplo n.º 2
0
 public static Apply_record GetLastApplyRecordbySenderID(string senderID)
 {
     using (var context = new DataModels())
     {
         return(context.Apply_record.Where(r => r.sender_id == senderID).Last());
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 获取全部虚拟机
        /// </summary>
        /// <returns></returns>
        private static List <VMConfig> GetAllVm()
        {
            List <VMConfig> configs;

            if (ManagerType.Equals("Sangfor"))
            {
                configs = restful.GetVMList(SangforDao.GetAllId());
                configs = SangforDao.MergeData(configs);
            }
            else
            {
                configs = manager.GetVMList();
                using (var context = new DataModels())
                {
                    List <VirtualMachine> virtualMachines = context.VirtualMachines.ToList();
                    foreach (var vm in virtualMachines)
                    {
                        var conf = configs.FirstOrDefault(c => c.Name.Equals(vm.vm_name));
                        if (conf != null)
                        {
                            conf.due_time = vm.due_time;
                        }
                    }
                }
            }
            return(configs);
        }
Ejemplo n.º 4
0
 public static List <Apply_record> GetAllApplyRecord()
 {
     using (var context = new DataModels())
     {
         return(context.Apply_record.ToList());
     }
 }
Ejemplo n.º 5
0
 void IBlogEngine.AddEntry(DataModels.Entry blogEntry)
 {
     using (IBlogService DataService = new BlogEngineDataService(this.Config))
     {
         DataService.AddBlogEntry(blogEntry);
     }
 }
 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());
     }
 }
Ejemplo n.º 7
0
        public UserInfo(DataModels.Twitter.User user)
        {
            Id = user.Id;
            Name = user.Name.Trim();
            ScreenName = user.ScreenName;
            Location = user.Location;
            Description = user.Description;
            try
            {
                ImageUrl = new Uri(user.ProfileImageUrl);
            }
            catch (Exception)
            {
                ImageUrl = null;
            }

            Url = user.Url;
            Protect = user.Protected;
            FriendsCount = user.FriendsCount;
            FollowersCount = user.FollowersCount;
            CreatedAt = MyCommon.DateTimeParse(user.CreatedAt);
            StatusesCount = user.StatusesCount;
            Verified = user.Verified;
            //// isFollowing = isFollowing;
            if (user.Status == null) return;

            RecentPost = user.Status.Text;
            PostCreatedAt = MyCommon.DateTimeParse(user.Status.CreatedAt);
            PostSource = user.Status.Source;
        }
 /// <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());
     }
 }
        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());
            }
        }
        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;
        }
Ejemplo n.º 11
0
        private async Task <bool> TestEditContact(string id, string first_name, string last_name, string nickname, string image,
                                                  string email, string phone, string phone_2, string skype, string country, string city, string status)
        {
            var jObj     = DataModels.GetDataModelUserInfo(id, first_name, last_name, nickname, image, email, phone, phone_2, skype, country, city, status);
            var modelExp = WebMsgParser.ParseResponsePersonalInfo(jObj.ToString());

            var statusCode = await _requests.Auth(email);

            if (statusCode != HttpStatusCode.OK)
            {
                return(false);
            }

            var response = await _requests.UpdateEditContactInfo(email, skype, country, city, phone);

            if (response.StatusCode != HttpStatusCode.OK)
            {
                return(false);
            }

            var responseStream = new StreamReader(response.Content.ReadAsStreamAsync().Result);
            var responseString = responseStream.ReadToEnd();

            responseStream.Dispose();

            var modelAct = WebMsgParser.ParseResponsePersonalInfo(responseString);

            var result = modelExp.Equals(modelAct);

            return(result);
        }
Ejemplo n.º 12
0
 public static List <string> GetUsersInDepart(string departId)
 {
     using (var dbContext = new DataModels())
     {
         return(dbContext.Users.Where(u => u.department_id == departId).Select(u => u.id).ToList());
     }
 }
Ejemplo n.º 13
0
        void IBlogService.AddBlogEntry(DataModels.Entry entry)
        {
            var Blog = this.Repository.GetBlogs().FirstOrDefault(b => b.Id == entry.BlogId);

            if (Blog != null)
            {
                var Entry = this.Repository.GetEntries().FirstOrDefault(e => e.Id == entry.Id && e.BlogId == entry.BlogId);

                if (Entry != null)
                {
                    this.Repository.Attach(entry);
                }
                else
                {
                    Entry = this.Repository.CreateEntry();
                }

                Entry.BlogId = entry.BlogId;
                Entry.CreateDate = entry.CreateDate;
                Entry.EditedDate = entry.EditedDate;
                Entry.EntryText = entry.EntryText;
                Entry.IsRawHtml = entry.IsRawHtml;
                Entry.Tags = entry.Tags;
                Entry.Title = entry.Title;

                this.Repository.Save();
            }
        }
 /*
  * Create By xzy
  *互评分数结算
  * 2019/8/1
  */
 public static string ComputeFinalScore(string stuId, int expId)
 {
     using (var dbContext = new DataModels())
     {
         Assignment             assignment = dbContext.Assignments.Where(a => a.student_id == stuId && a.experiment_id == expId).First();
         List <Peer_assessment> pa         = dbContext.Peer_assessment.Where(p => p.student_id == stuId && p.experiment_id == expId).ToList();
         int   cnt = 0;
         float res = 0;
         if (assignment.score == null)
         {
             foreach (var temp_pa in pa)
             {
                 if (temp_pa.score != null)
                 {
                     cnt++;
                     res += (float)temp_pa.score;
                 }
             }
             if (cnt != 0)
             {
                 assignment.score = res / cnt;
                 dbContext.SaveChanges();
                 return(assignment.score.ToString());
             }
             else
             {
                 return("评分数量为0");
             }
         }
         else
         {
             return(assignment.score.ToString());
         }
     }
 }
 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();
 }
 public static File GetFileById(string fileId)
 {
     using (var dbContext = new DataModels())
     {
         return(dbContext.Files.Find(fileId));
     }
 }
Ejemplo n.º 17
0
        private static void UpdateWebsiteConfirmButton_Click(object sender, RoutedEventArgs e)
        {
            Button        button  = (Button)sender;
            List <object> data    = (List <object>)button.Tag;
            Website       website = (Website)data[0];
            TextBox       websiteRatingTextBox = (TextBox)data[1];

            string websiteRating = websiteRatingTextBox.Text;

            if (!BackEndHelper.IsNumber(websiteRating))
            {
                MessageBox.Show("Rating must be a number");
                return;
            }
            int newRating = int.Parse(websiteRating);

            website.rating = newRating;
            DataModels database = DataModels.GetInstance();


            bool done = database.UpdateWebsite(website);

            if (done)
            {
                MessageBox.Show("Website Updated successfully !");
            }
            else
            {
                MessageBox.Show("Couldn't update website");
            }
        }
Ejemplo n.º 18
0
        public void HelloLabel_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            User user = ((LoggedinNavigationCanvas)currentNavigationCanvas).GetActiveUser();

            CurrentCanvas.Hide();
            InitializeBookingsListShowCanvas(DataModels.GetInstance().GetUserBookings(user));
        }
Ejemplo n.º 19
0
 // GET: Customer
 public ActionResult Index()
 {
     using (DataModels db = new DataModels())
     {
         return(View(db.Customers.ToList()));
     }
 }
Ejemplo n.º 20
0
        private static void AddWebsiteConfirmButton_Click(object sender, RoutedEventArgs e)
        {
            Button         button        = (Button)sender;
            List <TextBox> data          = (List <TextBox>)button.Tag;
            string         websiteName   = data[0].Text;
            string         websiteRating = data[1].Text;

            if (!BackEndHelper.IsNumber(websiteRating))
            {
                MessageBox.Show("Rating must be a number");
                return;
            }
            int        rating   = int.Parse(websiteRating);
            DataModels database = DataModels.GetInstance();
            Website    website  = new Website(websiteName, rating);
            bool       done     = database.AddWebsite(website);

            if (done)
            {
                MessageBox.Show("Website Added successfully !");
            }
            else
            {
                MessageBox.Show("Couldn't add website");
            }
        }
Ejemplo n.º 21
0
 public static List <Course> GetAllCourse()
 {
     using (var context = new DataModels())
     {
         return(context.Courses.ToList());
     }
 }
Ejemplo n.º 22
0
 // GET: Customer/Delete/5
 public ActionResult Delete(int id)
 {
     using (DataModels db = new DataModels())
     {
         return(View(db.Customers.Where(x => x.CustomerId == id).FirstOrDefault()));
     }
 }
Ejemplo n.º 23
0
 public static List <Assistant> GetAssistantsByStuId(string stuId)
 {
     using (var context = new DataModels())
     {
         return(context.Assistants.Where(a => a.student_id == stuId).ToList());
     }
 }
Ejemplo n.º 24
0
 public static List <Course> GetCourseByDepId(string depId)
 {
     using (var context = new DataModels())
     {
         return(context.Courses.Where(c => c.department_id == depId).ToList());
     }
 }
Ejemplo n.º 25
0
 /// <summary>
 /// 获取学院全部
 /// created by jyf
 /// 2019.7.29
 /// </summary>
 /// <returns>List<Department></returns>
 public static List <Department> GetDepartments()
 {
     using (var dbContext = new DataModels())
     {
         return(dbContext.Departments.ToList());
     }
 }
Ejemplo n.º 26
0
 public static List <Assistant> GetAssistantsByCourseId(int courseId)
 {
     using (var context = new DataModels())
     {
         return(context.Assistants.Where(a => a.course_id == courseId).ToList());
     }
 }
Ejemplo n.º 27
0
 public static List <Term> GetTerms()
 {
     using (var dbContext = new DataModels())
     {
         return(dbContext.Terms.ToList());
     }
 }
Ejemplo n.º 28
0
 /// <summary>
 /// 根据id查看学期名称
 /// created by jyf
 /// 2019.7.23
 /// </summary>
 /// <param name="id"></param>
 /// <returns>Term</returns>
 public static Term GetTermById(int id)
 {
     using (var dbContext = new DataModels())
     {
         return(dbContext.Terms.Find(id));
     }
 }
Ejemplo n.º 29
0
        private static void AddReviewConfirmButton_Click(object sender, RoutedEventArgs e)
        {
            DataModels    database      = DataModels.GetInstance();
            Button        addRoomButton = (Button)sender;
            List <object> objects       = (List <object>)addRoomButton.Tag;
            Booking       booking       = (Booking)objects[0];
            TextBox       reviewTextBox = (TextBox)objects[1];
            TextBox       ratingTexyBox = (TextBox)objects[2];

            if (!BackEndHelper.IsNumber(ratingTexyBox.Text))
            {
                MessageBox.Show("Rating must be a number !");
                return;
            }
            bool done = database.AddReview(new Review(reviewTextBox.Text, int.Parse(ratingTexyBox.Text), booking.number));

            if (done)
            {
                MessageBox.Show("Review submitted");
            }
            else
            {
                MessageBox.Show("Error!");
            }
        }
Ejemplo n.º 30
0
        private static void AddOfferConfirmButton_Click(object sender, RoutedEventArgs e)
        {
            DataModels    database     = DataModels.GetInstance();
            Button        button       = (Button)sender;
            List <object> data         = (List <object>)button.Tag;
            ComboBox      websiteCombo = (ComboBox)data[0];
            ComboBox      HotelCombo   = (ComboBox)data[1];
            ComboBox      RoomCombo    = (ComboBox)data[2];
            TextBox       priceText    = (TextBox)data[3];

            Website website = (Website)websiteCombo.SelectedItem;
            Room    room    = (Room)RoomCombo.SelectedItem;
            int     price   = int.Parse(priceText.Text);

            bool done = database.AddOffer(new Offer(website, room, price));

            if (done)
            {
                MessageBox.Show("Offer Added successfully !");
            }
            else
            {
                MessageBox.Show("Couldn't add offer");
            }
        }
Ejemplo n.º 31
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);
     }
 }
Ejemplo n.º 32
0
 //仅供测试
 public static Course GetCourse(int courseId)
 {
     using (var dbContext = new DataModels())
     {
         return(dbContext.Courses.Find(courseId));
     }
 }
 /*
  * Create By xzy
  * 随机抽取评分作业
  * 2019/7/18
  */
 public static List <Assignment> GenAssignmentsToMark(int expId)
 {
     using (var dbContext = new DataModels())
     {
         List <Assignment> assignments = dbContext.Assignments.Where(a => a.experiment_id == expId).ToList();
         List <Assignment> returnList  = new List <Assignment>();
         int assCount = assignments.Count();
         if (assCount < 6)
         {
             return(null);
         }
         else
         {
             Random random = new Random(DateTime.Now.Millisecond);
             int    r      = random.Next(0, assCount - 1);
             int    step   = random.Next(1, assCount / 6);
             int    cnt    = 0;
             while (cnt < 6)
             {
                 returnList.Add(assignments[r]);
                 assignments[r].is_standard = 1;
                 r = (r + step) % assCount;
                 cnt++;
             }
             dbContext.SaveChanges();
             return(returnList);
         }
     }
 }
Ejemplo n.º 34
0
 /// <summary>
 /// 按照applyId获取实验
 /// create by xzh
 /// 2019.8.9
 /// </summary>
 /// <param name="applyId"></param>
 /// <returns></returns>
 public static Experiment GetExperimentByApplyId(int applyId)
 {
     using (var dbContext = new DataModels())
     {
         return(dbContext.Experiments.Where(e => e.vm_apply_id == applyId).First());
     }
 }
Ejemplo n.º 35
0
        internal CompilationUnitSyntax GenerateCompilationUnit()
        {
            var ctx = SourceFileContext.CreateFullyQualified(SystemClock.Instance);
            var ns  = Namespace(PackageName);

            using (ctx.InNamespace(ns))
            {
                var serviceClass     = GenerateServiceClass(ctx);
                var baseRequestClass = GenerateBaseRequestClass(ctx);
                ns = ns.AddMembers(serviceClass, baseRequestClass);

                foreach (var resource in Resources)
                {
                    var resourceClass = resource.GenerateClass(ctx);
                    ns = ns.AddMembers(resourceClass);
                }
            }
            var dataNs = Namespace(PackageName + ".Data");

            using (ctx.InNamespace(dataNs))
            {
                var dataModels = DataModels
                                 .Where(dm => !dm.IsPlaceholder)
                                 .OrderBy(dm => dm.Typ.Name, StringComparer.Ordinal);
                foreach (var dataModel in dataModels)
                {
                    dataNs = dataNs.AddMembers(dataModel.GenerateClass(ctx));
                }
            }
            return(ctx.CreateCompilationUnit(ns).AddMembers(dataNs));
        }
Ejemplo n.º 36
0
        private static void AddRoomButton_Click(object sender, RoutedEventArgs e)
        {
            Button        addRoomButton         = (Button)sender;
            List <object> objects               = (List <object>)addRoomButton.Tag;
            ComboBox      hotelComboBox         = (ComboBox)objects[0];
            TextBox       roomNumberTextBox     = (TextBox)objects[1];
            ComboBox      roomTypeComboBox      = (ComboBox)objects[2];
            Button        browseRoomPhotoButton = (Button)objects[3];
            Window        popup    = (Window)objects[4];
            DataModels    database = DataModels.GetInstance();

            if (hotelComboBox.SelectedItem == null)
            {
                MessageBox.Show("Please select a hotel");
                return;
            }
            Hotel hotel = (Hotel)((ComboBoxItem)hotelComboBox.SelectedItem).Content;

            int roomNumber;

            if (!int.TryParse(roomNumberTextBox.Text, out roomNumber))
            {
                MessageBox.Show("Please enter a valid room number");
                return;
            }

            if (roomTypeComboBox.SelectedItem == null)
            {
                MessageBox.Show("Please select a room type");
                return;
            }
            RoomType roomType = (RoomType)((ComboBoxItem)roomTypeComboBox.SelectedItem).Content;

            if ((string)browseRoomPhotoButton.Tag == "")
            {
                MessageBox.Show("Please select a photo path");
                return;
            }
            CustomImage roomImage = new CustomImage((string)browseRoomPhotoButton.Tag);

            Room room = new Room(roomNumber, hotel, roomType, roomImage, new List <RoomView>());

            if (database.AddRoom(room) == true)
            {
                MessageBox.Show("Added");
                if (adminWindow.currentCanvas != null)
                {
                    adminWindow.currentCanvas.Hide();
                }
                adminWindow.InitializeRoomsCanvas(database.GetAllRooms());
                popup.Close();
                return;
            }
            else
            {
                MessageBox.Show("please enter a valid room number");
                return;
            }
        }
Ejemplo n.º 37
0
 public static ForumCategory DisplayCategory(DataModels.Forum.ForumCategories cat)
 {
     ForumCategory c = new ForumCategory();
     c.CategoryId = cat.CategoryId;
     c.CategoryName = cat.NameOfCategory;
     c.GroupId = cat.GroupId;
     return c;
 }
Ejemplo n.º 38
0
 /// <summary>
 /// 返回当前学期 Create By zzw
 /// </summary>
 /// <param></param>
 /// <returns>Term</returns>
 public static Term GetNowTerm()
 {
     using (var dbContext = new DataModels())
     {
         Term t = dbContext.Terms.OrderBy(term => term.id).ToList().Last();
         return(t);
     }
 }
Ejemplo n.º 39
0
 /// <summary>
 /// 添加助教到课程 Create By zzw
 /// </summary>
 /// <param name="ast"></param>
 /// <returns>成功返回1,没有改变返回0</returns>
 public static int AddAstToCourse(Assistant ast)
 {
     using (var dbContext = new DataModels())
     {
         dbContext.Assistants.Add(ast);
         return(dbContext.SaveChanges());
     }
 }
Ejemplo n.º 40
0
 /// <summary>
 /// 管理员添加学期 Create By zzw
 /// </summary>
 /// <param name="term"></param>
 /// <returns>成功返回1,没有改变返回0</returns>
 public static int AddTerm(Term term)
 {
     using (var dbContext = new DataModels())
     {
         dbContext.Terms.Add(term);
         return(dbContext.SaveChanges());
     }
 }
Ejemplo n.º 41
0
        public void AddFavourite(DataModels.StopInfo stopInfo)
        {
            var contains = (_favourites.Contains(stopInfo));

            if (!contains)
                Favourites.Add(stopInfo);

            SaveFavourites();
        }
Ejemplo n.º 42
0
        void IAuthorizerDataService.RegisterUserLogIn(DataModels.User user)
        {
            var DbUser = ThisService.Repository.GetUsers().FirstOrDefault(u => u.OpenId == user.OpenId);

            if (DbUser == null)
            {
                ThisService.Repository.AddUser(user);
                ThisService.Repository.Save();
            }
        }
Ejemplo n.º 43
0
 public static void ShowUserStatus(DataModels.User user)
 {
     Console.WriteLine("--------------USER STATUS-------------");
     Console.WriteLine(user.Id);
     Console.WriteLine(user.Age);
     Console.WriteLine(user.FirstName);
     Console.WriteLine(user.LastName);
     Console.WriteLine(user.Handicap);
     Console.WriteLine(user.Status);
     Console.WriteLine("--------------USER STATUS-------------");
 }
Ejemplo n.º 44
0
        private static TaskListDA DisplayTaskList(DataModels.League.Task.TaskList oTaskList)
        {
            TaskListDA bl = new TaskListDA();
            bl.AssignedTo = oTaskList.AssignedTo;
            bl.EndDate = oTaskList.EndDate;
            bl.ListAddByMember = oTaskList.ListAddByMember.MemberId;
            bl.ListId = oTaskList.ListId;
            bl.ListName = oTaskList.ListName;
            bl.TaskListForLeague = oTaskList.TaskListForLeague.LeagueId;

            return bl;
        }
 public static bool AddEmailToContactCard(string email, DataModels.ContactCard.ContactCard contact)
 {
     try
     {
         contact.Emails.Add(new RDN.Library.DataModels.ContactCard.Email { EmailAddress = email, IsDefault = true });
         return true;
     }
     catch (Exception exception)
     {
         ErrorDatabaseManager.AddException(exception, exception.GetType());
     }
     return false;
 }
 public static bool UpdateEmailToContactCard(string email, DataModels.ContactCard.Email emailCard)
 {
     try
     {
         emailCard.EmailAddress = email;
         return true;
     }
     catch (Exception exception)
     {
         ErrorDatabaseManager.AddException(exception, exception.GetType());
     }
     return false;
 }
		/// <summary>
		/// Retrieve a cached (and pre-parsed) callstack container from the cache, or parse the raw callstack, and add to the cache.
		/// </summary>
		/// <param name="CurrentCrash">The crash to retrieve the parsed callstack for.</param>
		/// <returns>A parsed callstack.</returns>
		public DataModels.CallStackContainer GetCallStackFast( DataModels.Crash CurrentCrash )
		{
			using( var logTimer = new FAutoScopedLogTimer( this.GetType().ToString() + "(CrashId=" + CurrentCrash.Id + ")" ) )
			{
				var key = CacheKeyPrefix + CallstackKeyPrefix + CurrentCrash.Id;
				var callStack = (CallStackContainer)CacheInstance[key];
			    if (callStack != null) return callStack;
			    callStack = new CallStackContainer( CurrentCrash );
			    callStack.bDisplayFunctionNames = true;
			    CacheInstance.Insert( key, callStack );

			    return callStack;
			}
		}
Ejemplo n.º 48
0
        void IAuthorizerDataService.RegisterUserAlias(string openId, DataModels.UserAlias alias)
        {
            var DbUser = ThisService.Repository.GetUsers().FirstOrDefault(u => u.OpenId == openId);
            var DbAlias = ThisService.Repository.GetAliases().FirstOrDefault(a => a.Id == DbUser.AliasId);

            if (DbAlias == null)
            {
                ThisService.Repository.AddAlias(alias);
                ThisService.Repository.Save();
                DbUser.AliasId = ThisService.Repository.Context.Entry(alias).Entity.Id;
                ThisService.Repository.UpdateUser(DbUser);
                ThisService.Repository.Save();
            }
        }
Ejemplo n.º 49
0
        void IBlogService.AddComment(DataModels.Comment comment)
        {
            var Comment = this.Repository.GetComments().FirstOrDefault(c => c.Id == comment.Id);

            if (Comment == null)
            {
                Comment = this.Repository.CreateComment();

                Comment.By = comment.By;
                Comment.CanRespond = comment.CanRespond;
                Comment.CommentDate = comment.CommentDate;
                Comment.Content = comment.Content;
                Comment.EntryId = comment.EntryId;
            }
        }
Ejemplo n.º 50
0
        /// <summary>
        /// inserts the team into the DB.
        /// </summary>
        /// <param name="game"></param>
        /// <param name="team"></param>
        /// <param name="db"></param>
        public static void insertTeamIntoDb(GameViewModel game, TeamViewModel team, ManagementContext db, DataModels.Game.Game g)
        {
            try
            {
                DataModels.Game.GameTeam tm = new DataModels.Game.GameTeam();
                tm.Created = DateTime.UtcNow;
                tm.Game = g;
                if (String.IsNullOrEmpty(team.TeamName))
                    tm.TeamName = "Temp";
                else
                    tm.TeamName = team.TeamName;

                if (team.TeamId == new Guid())
                    tm.TeamId = Guid.NewGuid();
                else
                    tm.TeamId = team.TeamId;

                if (team.Logo != null && team.Logo.TeamLogoId != new Guid())
                {
                    var logo = db.TeamLogos.Where(x => x.TeamLogoId == team.Logo.TeamLogoId).FirstOrDefault();
                    if (logo != null)
                    {
                        tm.Logo = logo;
                        team.Logo.ImageUrl = logo.ImageUrl;
                        team.Logo.ImageUrlThumb = logo.ImageUrlThumb;
                    }
                }
                if (team.LineUpSettings != null)
                {
                    UpdateLineUpSettings(team, tm);
                }

                db.GameTeam.Add(tm);

                foreach (var member in team.TeamMembers)
                {
                    GameMemberClass.insertNewSkater(game.GameId, db, tm.TeamId, member, tm);
                }

                //TODO:record time outs left.
                db.SaveChanges();
            }
            catch (Exception exception)
            {
                ErrorDatabaseManager.AddException(exception, exception.GetType());
            }
        }
Ejemplo n.º 51
0
        /// <summary>
        /// entry point for updating the team.
        /// </summary>
        /// <param name="game"></param>
        /// <param name="team"></param>
        /// <param name="db"></param>
        public static void updateTeam(GameViewModel game, TeamViewModel team, ManagementContext db, DataModels.Game.Game g)
        {
            try
            {
                var getTeam = g.GameTeams.Where(x => x.TeamId == team.TeamId).FirstOrDefault();

                if (getTeam == null)
                {
                    insertTeamIntoDb(game, team, db, g);
                }
                else
                {

                    if (String.IsNullOrEmpty(team.TeamName))
                        getTeam.TeamName = "Temp";
                    else
                        getTeam.TeamName = team.TeamName;
                    if (team.Logo != null)
                    {
                        if ((getTeam.Logo == null) || (getTeam.Logo != null && getTeam.Logo.TeamLogoId != team.Logo.TeamLogoId))
                        {
                            var logo = db.TeamLogos.Where(x => x.TeamLogoId == team.Logo.TeamLogoId).FirstOrDefault();
                            if (logo != null)
                            {
                                getTeam.Logo = logo;
                                team.Logo.ImageUrl = logo.ImageUrl;
                                team.Logo.ImageUrlThumb = logo.ImageUrlThumb;
                            }
                        }
                    }

                    getTeam.CurrentTimeouts = team.TimeOutsLeft;
                    getTeam.LeageName = team.LeagueName;
                    if (team.LineUpSettings != null)
                    {
                        UpdateLineUpSettings(team, getTeam);
                    }

                }
                db.SaveChanges();
            }
            catch (Exception exception)
            {
                ErrorDatabaseManager.AddException(exception, exception.GetType(), additionalInformation: "tried to update the team");
            }
        }
Ejemplo n.º 52
0
        private bool AnalizeUserInfo(DataModels.Twitter.User user)
        {
            if (user == null)
            {
                return false;
            }

            try
            {
                _info.Id = user.Id;
                _info.Name = user.Name.Trim();
                _info.ScreenName = user.ScreenName;
                _info.Location = user.Location;
                _info.Description = user.Description;
                _info.ImageUrl = new Uri(user.ProfileImageUrl);
                _info.Url = user.Url;
                _info.Protect = user.Protected;
                _info.FriendsCount = user.FriendsCount;
                _info.FollowersCount = user.FollowersCount;
                _info.FavoriteCount = user.FavouritesCount;
                _info.CreatedAt = MyCommon.DateTimeParse(user.CreatedAt);
                _info.StatusesCount = user.StatusesCount;
                _info.Verified = user.Verified;
                try
                {
                    _info.RecentPost = user.Status.Text;
                    _info.PostCreatedAt = MyCommon.DateTimeParse(user.Status.CreatedAt);
                    _info.PostSource = user.Status.Source;
                    if (!_info.PostSource.Contains("</a>"))
                    {
                        _info.PostSource += "</a>";
                    }
                }
                catch (Exception)
                {
                    _info.RecentPost = null;
                    _info.PostSource = null;
                }
            }
            catch (Exception)
            {
                return false;
            }

            return true;
        }
 /// <summary>
 /// gets the member of a particular team from the game in the DB.
 /// </summary>
 /// <param name="teamId"></param>
 /// <param name="jam"></param>
 /// <param name="g"></param>
 /// <returns></returns>
 public static GameMember getMemberOfTeamInGame(Guid teamId, Guid skaterId, DataModels.Game.Game g)
 {
     try
     {
         if (g.GameTeams != null && g.GameTeams.Count > 0)
         {
             var t = g.GameTeams.Where(x => x.TeamId == teamId).FirstOrDefault();
             if (t == null)
                 return null;
             var m = t.GameMembers.Where(x => x.GameMemberId == skaterId).FirstOrDefault();
             return m;
         }
     }
     catch (Exception exception)
     {
         ErrorDatabaseManager.AddException(exception, exception.GetType());
     }
     return null;
 }
 public static bool UpdateEmailToContactCard(string email, DataModels.ContactCard.ContactCard card)
 {
     try
     {
         if (card.Emails.FirstOrDefault() == null)
         {
             DataModels.ContactCard.Email e = new DataModels.ContactCard.Email();
             UpdateEmailToContactCard(email, e);
             card.Emails.Add(e);
         }
         else
             UpdateEmailToContactCard(email, card.Emails.FirstOrDefault());
         return true;
     }
     catch (Exception exception)
     {
         ErrorDatabaseManager.AddException(exception, exception.GetType());
     }
     return false;
 }
        /// <summary>
        /// updates the team assists to the DB.
        /// </summary>
        /// <param name="team"></param>
        /// <param name="teamId"></param>
        /// <param name="game"></param>
        /// <param name="db"></param>
        /// <param name="g"></param>
        public static void updateTeamAssists(TeamNumberEnum team, Guid teamId, GameViewModel game, ManagementContext db, DataModels.Game.Game g)
        {
            try
            {
                List<AssistViewModel> assitsNew = new List<AssistViewModel>();

                if (team == TeamNumberEnum.Team1)
                    assitsNew = game.AssistsForTeam1;
                else
                    assitsNew = game.AssistsForTeam2;

                for (int i = 0; i < assitsNew.Count; i++)
                {
                    insertAssistIntoDb(teamId, game, assitsNew[i], db, g);
                }

            }
            catch (Exception exception)
            {
                ErrorDatabaseManager.AddException(exception, exception.GetType(), additionalInformation: "tried updating team scores");
            }
        }
 public static void AddOfficialReview(GameViewModel game, DataModels.Game.Game gameNew, OfficialReviewViewModel review)
 {
     try
     {
         GameOfficialReview or = new GameOfficialReview();
         or.CurrentDateTimeReviewed = review.CurrentDateTimeReviewed;
         or.Details = review.Details;
         or.Game = gameNew;
         or.JamId = review.JamId;
         or.JamNumber = review.JamNumber;
         or.OfficialReviewIdFromGame = review.OfficialReviewId;
         or.Period = review.Period;
         or.PeriodTimeRemaining = review.PeriodTimeRemaining;
         or.Result = review.Result;
         or.TeamNumber = (byte)review.TeamNumber;
         gameNew.OfficialReviews.Add(or);
     }
     catch (Exception exception)
     {
         ErrorDatabaseManager.AddException(exception, exception.GetType());
     }
 }
 public static void AddOfficialToGame(GameViewModel game, ManagementContext db, DataModels.Game.Game gameNew, Guid skaterId, string skaterName, OfficialTypeEnum officialType, int refereeType, CertificationLevelEnum cert)
 {
     try
     {
         if (!String.IsNullOrEmpty(skaterName))
         {
             GameOfficial o = new GameOfficial();
             o.Game = gameNew;
             o.GameOfficialId = skaterId;
             o.MemberName = skaterName;
             o.OfficialTypeEnum = Convert.ToInt32(officialType);
             o.RefereeType = refereeType;
             o.CertificationLevelEnum = (byte)cert;
             db.GameOfficials.Add(o);
             db.SaveChanges();
         }
     }
     catch (Exception exception)
     {
         ErrorDatabaseManager.AddException(exception, exception.GetType());
     }
 }
 private static void UpdateOfficialToDb(GameViewModel game, ManagementContext db, DataModels.Game.Game gameNew, Guid skaterId, string skaterName, OfficialTypeEnum officialType, int refereeType, CertificationLevelEnum cert)
 {
     try
     {
         var off = db.GameOfficials.Where(x => x.GameOfficialId == skaterId).FirstOrDefault();
         if (off != null && !String.IsNullOrEmpty(skaterName))
         {
             off.Game = gameNew;
             off.MemberName = skaterName;
             off.OfficialTypeEnum = Convert.ToInt32(officialType);
             off.RefereeType = refereeType;
             off.CertificationLevelEnum = (byte)cert;
         }
         else
         {
             AddOfficialToGame(game, db, gameNew, skaterId, skaterName, officialType, refereeType, cert);
         }
     }
     catch (Exception exception)
     {
         ErrorDatabaseManager.AddException(exception, exception.GetType());
     }
 }
        public static int DeepCompareOfficialsToDb(GameViewModel game, ManagementContext db, DataModels.Game.Game gameNew)
        {
            try
            {
                if (game.Officials != null)
                {
                    foreach (var member in game.Officials.Nsos)
                    {
                        UpdateOfficialToDb(game, db, gameNew, member.SkaterId, member.SkaterName, OfficialTypeEnum.NSO, Convert.ToInt32(member.RefereeType), member.Cert);
                    }
                    foreach (var member in game.Officials.Referees)
                    {
                        UpdateOfficialToDb(game, db, gameNew, member.SkaterId, member.SkaterName, OfficialTypeEnum.Referee, Convert.ToInt32(member.RefereeType), member.Cert);
                    }

                }
            }
            catch (Exception exception)
            {
                ErrorDatabaseManager.AddException(exception, exception.GetType());
            }
            return db.SaveChanges();
        }
        /// <summary>
        /// updates the team penalties to the DB.
        /// </summary>
        /// <param name="team"></param>
        /// <param name="teamId"></param>
        /// <param name="game"></param>
        /// <param name="db"></param>
        /// <param name="g"></param>
        public static void updateTeamPenalties(TeamNumberEnum team, Guid teamId, GameViewModel game, ManagementContext db, DataModels.Game.Game g)
        {
            try
            {
                List<PenaltyViewModel> blocksNew = new List<PenaltyViewModel>();

                if (team == TeamNumberEnum.Team1 && game.PenaltiesForTeam1 != null)
                    blocksNew = game.PenaltiesForTeam1;
                else if (team == TeamNumberEnum.Team1 && game.PenaltiesForTeam2 != null)
                    blocksNew = game.PenaltiesForTeam2;

                for (int i = 0; i < blocksNew.Count; i++)
                {
                    var blockDb = g.GameMemberPenalties.Where(x => x.GamePenaltyId == blocksNew[i].PenaltyId).FirstOrDefault();

                    if (blockDb == null)
                        insertPenaltyIntoDb(teamId, game, blocksNew[i], db, g);
                }
            }
            catch (Exception exception)
            {
                ErrorDatabaseManager.AddException(exception, exception.GetType(), additionalInformation: "tried updating team scores");
            }
        }