public static int Add(SqlConnection connection, WebCommModel model, PunchCard type) { string strSql = @" INSERT INTO [dbo].[WEBCOMM] ([WBC_SERNO] ,[WBC_DATE] ,[WBC_CLOCKIN] ,[WBC_CLOCKOUT]) VALUES (@WBC_SERNO ,@WBC_DATE ,@WBC_CLOCKIN ,@WBC_CLOCKOUT) "; SqlCommand command = new SqlCommand(strSql, connection); if (connection.State != System.Data.ConnectionState.Open) { connection.Open(); } if (string.IsNullOrEmpty(model.WBC_SERNO)) { command.Parameters.AddWithValue("@WBC_SERNO", DBNull.Value); } else { command.Parameters.AddWithValue("@WBC_SERNO", model.WBC_SERNO); } if (string.IsNullOrEmpty(model.WBC_DATE)) { command.Parameters.AddWithValue("@WBC_DATE", DBNull.Value); } else { command.Parameters.AddWithValue("@WBC_DATE", model.WBC_DATE); } if (string.IsNullOrEmpty(model.WBC_CLOCKIN)) { command.Parameters.AddWithValue("@WBC_CLOCKIN", DBNull.Value); } else { command.Parameters.AddWithValue("@WBC_CLOCKIN", model.WBC_CLOCKIN); } if (string.IsNullOrEmpty(model.WBC_CLOCKOUT)) { command.Parameters.AddWithValue("@WBC_CLOCKOUT", DBNull.Value); } else { command.Parameters.AddWithValue("@WBC_CLOCKOUT", model.WBC_CLOCKOUT); } return(command.ExecuteNonQuery()); }
public void DoesNotThrowExceptionWhenPunchPointsHaveCorrectFormat() { IList <int> point1 = new[] { 1, 2, 3 }; IEnumerable <IList <int> > points = new List <IList <int> > { point1 }; var punchcard = new PunchCard(points); }
public IActionResult Transfer(PunchCard punchCard, string ddlTransferMembers) { punchCard.CurrentMemberID = int.Parse(ddlTransferMembers); TempData["SelectedMemberID"] = punchCard.CurrentMemberID; _punchCardRepository.TransferPunchCard(punchCard); TempData["Message"] = "Punch card transferred."; TempData["Style"] = "alert alert-info"; return(RedirectToAction("Index", "PunchCard")); }
public IActionResult Purchase(PunchCard newPunchCard, string ddlSelectMembers) { var memberID = int.Parse(ddlSelectMembers); newPunchCard.PurchaseMemberID = memberID; TempData["SelectedMemberID"] = memberID; _punchCardRepository.PurchasePunchCard(newPunchCard); return(RedirectToAction("Index", "PunchCard")); }
public static PunchCard CreatePunchCard(IEnumerable <Commit> commits) { var punchCard = new PunchCard(); foreach (var commit in commits) { punchCard.SetOrElseUpdate(commit.DateTime.DayOfWeek, commit.DateTime.Hour, commit.ChangeCount, (a, b) => a + b); } return(punchCard); }
public void SetsPunchPointsAsReadOnlyDictionary() { IList <int> point1 = new[] { 1, 0, 3 }; IList <int> point2 = new[] { 1, 1, 4 }; IList <int> point3 = new[] { 1, 2, 0 }; IEnumerable <IList <int> > points = new List <IList <int> > { point1, point2, point3 }; var punchCard = new PunchCard(points); AssertEx.IsReadOnlyCollection <PunchCardPoint>(punchCard.PunchPoints); }
public void CanQueryCommitsForDayAndHour() { IList <int> point1 = new[] { 1, 0, 3 }; IList <int> point2 = new[] { 1, 1, 4 }; IList <int> point3 = new[] { 1, 2, 0 }; IEnumerable <IList <int> > points = new List <IList <int> > { point1, point2, point3 }; var punchCard = new PunchCard(points); var commitsAtMondayAt12Am = punchCard.GetCommitCountFor(DayOfWeek.Monday, 0); var commitsAtMondayAt1Am = punchCard.GetCommitCountFor(DayOfWeek.Monday, 1); var commitsAtMondayAt2Am = punchCard.GetCommitCountFor(DayOfWeek.Monday, 2); var commitsAtTuesdayAt2Am = punchCard.GetCommitCountFor(DayOfWeek.Tuesday, 2); Assert.Equal(3, commitsAtMondayAt12Am); Assert.Equal(4, commitsAtMondayAt1Am); Assert.Equal(0, commitsAtMondayAt2Am); Assert.Equal(0, commitsAtTuesdayAt2Am); }