Beispiel #1
0
        public ActionResult Shifts(int id)
        {
            List <Models.Shift> shifts = new List <Models.Shift>();

            using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString))
            {
                connection.Open();
                String sql = "Select * From Shift WHERE EventId = " + id;

                using (SqlCommand command = new SqlCommand(sql, connection))
                {
                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            var s = new Models.Shift();
                            s.Id        = Convert.ToInt32(reader["id"]);
                            s.EventId   = Convert.ToInt32(reader["EventId"]);
                            s.UserId    = Convert.ToInt32(reader["UserId"]);
                            s.StartTime = Convert.ToDateTime(reader["StartTime"]);
                            s.EndTime   = s.StartTime.AddHours(2); //Convert.ToDateTime(reader["EndTime"]);
                            shifts.Add(s);
                        }
                    }
                }
            }


            return(View());
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="GetShiftResponse"/> class.
 /// </summary>
 /// <param name="shift">shift.</param>
 /// <param name="errors">errors.</param>
 public GetShiftResponse(
     Models.Shift shift          = null,
     IList <Models.Error> errors = null)
 {
     this.Shift  = shift;
     this.Errors = errors;
 }
Beispiel #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CreateShiftRequest"/> class.
 /// </summary>
 /// <param name="shift">shift.</param>
 /// <param name="idempotencyKey">idempotency_key.</param>
 public CreateShiftRequest(
     Models.Shift shift,
     string idempotencyKey = null)
 {
     this.IdempotencyKey = idempotencyKey;
     this.Shift          = shift;
 }
Beispiel #4
0
        public decimal GetHourlyWage(Models.Shift shift)
        {
            var hours = GetHoursWorked(shift);

            // Prevent division by zero.
            if (hours > 0)
            {
                return(shift.TotalTips / (decimal)GetHoursWorked(shift));
            }

            // Return the total tips if there was zero hours worked.
            return(shift.TotalTips);
        }
 /// <summary>
 /// Shift.
 /// </summary>
 /// <param name="shift"> shift. </param>
 /// <returns> Builder. </returns>
 public Builder Shift(Models.Shift shift)
 {
     this.shift = shift;
     return(this);
 }
 public UpdateShiftResponse(Models.Shift shift          = null,
                            IList <Models.Error> errors = null)
 {
     Shift  = shift;
     Errors = errors;
 }
 public Builder(Models.Shift shift)
 {
     this.shift = shift;
 }
 public UpdateShiftRequest(Models.Shift shift)
 {
     Shift = shift;
 }
Beispiel #9
0
 public Builder Shift(Models.Shift value)
 {
     shift = value;
     return(this);
 }
Beispiel #10
0
 public double GetHoursWorked(Models.Shift shift)
 {
     return((shift.End - shift.Start).TotalHours);
 }
Beispiel #11
0
 public decimal GetTipout(Models.Shift shift, int percentage = 10)
 {
     return(Math.Round((shift.TotalTips * percentage) / 100, 2, MidpointRounding.AwayFromZero));
 }