Esempio n. 1
0
        public bool CreateStandingTeeTimeRequest(StandingTeeTime request)
        {
            bool             Confirmation = false;
            StandingTeeTimes dataManager  = new StandingTeeTimes();

            Confirmation = dataManager.CreateStandingTeeTimeRequest(request);
            return(Confirmation);
        }
Esempio n. 2
0
        public IActionResult OnPost()
        {
            Confirmation = false;
            StandingTeeTime request = new StandingTeeTime();

            if (ModelState.IsValid)
            {
                CBS RequestDirector = new CBS();

                DateTime.TryParse(StartDate, out DateTime startDate);
                DateTime.TryParse(EndDate, out DateTime endDate);
                TimeSpan time = Convert.ToDateTime(Time).TimeOfDay;

                int memberNumber1;
                int memberNumber2;
                int memberNumber3;
                int memberNumber4;
                int.TryParse(MemberNumber1, out memberNumber1);
                int.TryParse(MemberNumber2, out memberNumber2);
                int.TryParse(MemberNumber3, out memberNumber3);
                int.TryParse(MemberNumber4, out memberNumber4);

                request.MemberNumber1 = memberNumber1;
                request.MemberNumber2 = memberNumber2;
                request.MemberNumber3 = memberNumber3;
                request.MemberNumber4 = memberNumber4;
                request.MemberName1   = MemberName1;
                request.MemberName2   = MemberName2;
                request.MemberName3   = MemberName3;
                request.MemberName4   = MemberName4;
                request.DayOfWeek     = startDate;
                request.Time          = time;
                request.StartDate     = startDate;
                request.EndDate       = endDate;


                Confirmation = RequestDirector.CreateStandingTeeTimeRequest(request);

                if (Confirmation)
                {
                    TempData["Alert"] = $"Successfully Created Standing Tee Time Request";
                    return(RedirectToPage("/Index"));
                }
                else
                {
                    TempData["Danger"] = true;
                    Alert = $"Could Not Create Standing Tee Time Request";
                }
            }
            return(Page());
        }
Esempio n. 3
0
        public IActionResult OnPostCancel()
        {
            FoundStandingTeeTime = HttpContext.Session.Get <StandingTeeTime>(nameof(FoundStandingTeeTime));

            Domain.CBS requestDirector = new Domain.CBS(Startup.ConnectionString);
            if (requestDirector.CancelStandingTeeTime(FoundStandingTeeTime.StartDate, FoundStandingTeeTime.EndDate, FoundStandingTeeTime.RequestedTime))
            {
                HttpContext.Session.SetString("success", "Standing tee time request cancelled succcessfully");
            }
            else
            {
                HttpContext.Session.SetString("danger", "Standing tee time request could not be cancelled");
            }
            return(LocalRedirect("/"));
        }
        public void OnPost()
        {
            bool confirm       = false;
            CBS  systemControl = new CBS();

            string[] subs = Submit.Split(' ');


            switch (subs[0])
            {
            case "Cancel":
                StandingTeeTime teeTime = new StandingTeeTime();
                teeTime.StandingTeeTimeID = int.Parse(subs[1]);
                teeTime.IsCancelled       = true;
                confirm = systemControl.ModifyStandingTeeTime(teeTime);
                break;
            }
            _sampleObjectCollection = systemControl.GetStandingTeeTimeList();
        }
    public List <StandingTeeTime> GetStandingRequests()
    {
        SqlConnection dbConnection = new SqlConnection();

        //School
        //dbConnection.ConnectionString = "Persist Security Info=false;Integrated Security=true;Server=(LocalDb)\\MSSQLLocalDB;Database=ClubBaist;";
        //home
        dbConnection.ConnectionString = "Persist Security Info=false;Integrated Security=true;Server=.;Database=ClubBaist;";
        dbConnection.Open();

        SqlCommand getTeeTimesCommand = new SqlCommand();

        getTeeTimesCommand.Connection  = dbConnection;
        getTeeTimesCommand.CommandText = "GetStandingRequests";
        getTeeTimesCommand.CommandType = CommandType.StoredProcedure;

        List <StandingTeeTime> teeTimeRequests = new List <StandingTeeTime>();

        SqlDataReader dbReader = getTeeTimesCommand.ExecuteReader();

        if (dbReader.HasRows)
        {
            while (dbReader.Read())
            {
                StandingTeeTime teetimeRequest = new StandingTeeTime();
                string          id             = dbReader["StandingTeeTimeID"].ToString();
                teetimeRequest.StandingTeeTimeID = int.Parse(id);
                teetimeRequest.StartDate         = Convert.ToDateTime(dbReader["StartDate"].ToString());
                teetimeRequest.EndDate           = Convert.ToDateTime(dbReader["EndDate"].ToString());
                teetimeRequest.TeeTimeTime       = Convert.ToDateTime(dbReader["TeeTimeTime"].ToString());
                teetimeRequest.Approved          = (bool)dbReader["Approved"];
                teeTimeRequests.Add(teetimeRequest);
            }
        }

        dbConnection.Close();

        return(teeTimeRequests);
    }
 public void OnPost()
 {
     // Message = "OnPost";
     if (ModelState.IsValid)
     {
         bool            Confirmation;
         StandingTeeTime newStandingTeeTimeRequest = new StandingTeeTime
         {
             ShareHolderNumber  = Member1NumField,
             MemberNumber2      = Member2NumField,
             MemberNumber3      = Member3NumField,
             MemberNumber4      = Member4NumField,
             ShareHolderName    = Member1NameField,
             Member2Name        = Member2NameField,
             Member3Name        = Member3NameField,
             Member4Name        = Member4NameField,
             DateStart          = StartDateField,
             DateEnd            = EndDateField,
             TeeTimeTime        = TeeTimeTimeField,
             RequestedDayOfWeek = Convert.ToInt32(DayOfWeek) + 1
         };
         CBS RequestDirector = new CBS();
         Confirmation = RequestDirector.InsertStandingTeeTimeRequest(newStandingTeeTimeRequest);
         if (Confirmation == false)
         {
             Message = $"Successfully added Standing Tee Time Request for {Member1NameField}";
         }
         else
         {
             Message = $"Error adding Standing Tee Time Request for {Member1NameField}";
         }
     }
     else
     {
         Message = $"Not Valid";
     }
 }
Esempio n. 7
0
        public List <StandingTeeTime> GetStandingTeeTimeRequests(string user, string password)
        {
            List <StandingTeeTime> standingTeeTimeRequests;

            ConfigurationBuilder configurationBuilder = new ConfigurationBuilder();

            configurationBuilder.SetBasePath(Directory.GetCurrentDirectory());
            configurationBuilder.AddJsonFile("appsettings.json");
            IConfiguration configuration       = configurationBuilder.Build();
            SqlConnection  ClubBaistConnection = new SqlConnection(configuration.GetConnectionString("BAIS3230"));

            ClubBaistConnection.Open();
            SqlCommand UpdateMACommand = new SqlCommand();


            SqlCommand MACommand = new SqlCommand
            {
                Connection  = ClubBaistConnection,
                CommandType = CommandType.StoredProcedure,
                CommandText = "GetStandingTeeTimes"
            };

            SqlDataReader ApplicationReader;

            ApplicationReader       = MACommand.ExecuteReader();
            standingTeeTimeRequests = new List <StandingTeeTime>();
            if (ApplicationReader.HasRows)
            {
                Console.WriteLine("Columns:");
                Console.WriteLine("--------");
                for (int index = 0; index < ApplicationReader.FieldCount; index++)
                {
                    Console.WriteLine(ApplicationReader.GetName(index));
                }
                Console.WriteLine("Values:");
                Console.WriteLine("-------");
                for (int index = 0; index < ApplicationReader.FieldCount; index++)
                {
                    while (ApplicationReader.Read())
                    {
                        StandingTeeTime tee = new StandingTeeTime();
                        tee.StandingTeeTimeID = int.Parse(ApplicationReader.GetValue("StandingTeeTimeID").ToString());
                        tee.ShareHolderNumber = int.Parse(ApplicationReader.GetValue("ShareHolderNumber").ToString());

                        tee.MemberNumber2 = int.Parse(ApplicationReader.GetValue("MemberNumber2").ToString());
                        tee.MemberNumber3 = int.Parse(ApplicationReader.GetValue("MemberNumber3").ToString());


                        tee.MemberNumber4 = int.Parse(ApplicationReader.GetValue("MemberNumber4").ToString());

                        tee.ShareHolderName = ApplicationReader.GetValue("ShareholderName").ToString();

                        tee.Member2Name = ApplicationReader.GetValue("MemberName2").ToString();

                        tee.Member3Name = ApplicationReader.GetValue("MemberName3").ToString();
                        tee.Member4Name = ApplicationReader.GetValue("MemberName4").ToString();
                        tee.DateStart   = DateTime.Parse(ApplicationReader.GetValue("StartDate").ToString());

                        tee.DateEnd = DateTime.Parse(ApplicationReader.GetValue("EndDate").ToString());

                        tee.TeeTimeTime = DateTime.Parse(ApplicationReader.GetValue("TeeTimeTime").ToString());


                        tee.RequestedDayOfWeek = int.Parse(ApplicationReader.GetValue("RequestedDayOfWeek").ToString());
                        tee.RequestedDayOfWeek = tee.RequestedDayOfWeek - 1;


                        tee.IsApproved = bool.Parse(ApplicationReader.GetValue("IsApproved").ToString());
                        standingTeeTimeRequests.Add(tee);
                    }
                }
            }
            ApplicationReader.Close();
            ClubBaistConnection.Close();
            return(standingTeeTimeRequests);
        }
Esempio n. 8
0
        public bool ModifyStandingTeeTimeRequest(StandingTeeTime newStandingTeeTimeRequest, string user, string password)
        {
            bool sqlError = false;

            Console.WriteLine("ModifyStandingTeeTime");
            ConfigurationBuilder configurationBuilder = new ConfigurationBuilder();

            configurationBuilder.SetBasePath(Directory.GetCurrentDirectory());
            configurationBuilder.AddJsonFile("appsettings.json");
            IConfiguration configuration       = configurationBuilder.Build();
            SqlConnection  ClubBaistConnection = new SqlConnection(configuration.GetConnectionString("BAIS3230"));

            ClubBaistConnection.Open();
            SqlCommand addStandingTeeTimeRequestCommand = new SqlCommand()
            {
                CommandText = "ModifyStandingTeeTime",
                CommandType = CommandType.StoredProcedure,
                Connection  = ClubBaistConnection,
            };
            SqlParameter StandingTeeTimeIDParam = new SqlParameter()
            {
                Direction     = ParameterDirection.Input,
                ParameterName = "@StandingTeeTimeID",
                SqlDbType     = SqlDbType.Int,
                SqlValue      = newStandingTeeTimeRequest.StandingTeeTimeID
            };

            addStandingTeeTimeRequestCommand.Parameters.Add(StandingTeeTimeIDParam);
            SqlParameter ShareHolderNumberParam = new SqlParameter()
            {
                Direction     = ParameterDirection.Input,
                ParameterName = "@ShareHolderNumber",
                SqlDbType     = SqlDbType.Int,
                SqlValue      = newStandingTeeTimeRequest.ShareHolderNumber
            };

            addStandingTeeTimeRequestCommand.Parameters.Add(ShareHolderNumberParam);
            SqlParameter MemberNumber2Param = new SqlParameter()
            {
                Direction     = ParameterDirection.Input,
                ParameterName = "@MemberNumber2",
                SqlDbType     = SqlDbType.Int,
                SqlValue      = newStandingTeeTimeRequest.MemberNumber2
            };

            addStandingTeeTimeRequestCommand.Parameters.Add(MemberNumber2Param);
            SqlParameter MemberNumber3Param = new SqlParameter()
            {
                Direction     = ParameterDirection.Input,
                ParameterName = "@MemberNumber3",
                SqlDbType     = SqlDbType.Int,
                SqlValue      = newStandingTeeTimeRequest.MemberNumber3
            };

            addStandingTeeTimeRequestCommand.Parameters.Add(MemberNumber3Param);
            SqlParameter MemberNumber4Param = new SqlParameter()
            {
                Direction     = ParameterDirection.Input,
                ParameterName = "@MemberNumber4",
                SqlDbType     = SqlDbType.Int,
                SqlValue      = newStandingTeeTimeRequest.MemberNumber4
            };

            addStandingTeeTimeRequestCommand.Parameters.Add(MemberNumber4Param);
            SqlParameter ShareHolderNameParam = new SqlParameter()
            {
                Direction     = ParameterDirection.Input,
                ParameterName = "@ShareHolderName",
                SqlDbType     = SqlDbType.NVarChar,
                SqlValue      = newStandingTeeTimeRequest.ShareHolderName
            };

            addStandingTeeTimeRequestCommand.Parameters.Add(ShareHolderNameParam);
            SqlParameter Member2NameParam = new SqlParameter()
            {
                Direction     = ParameterDirection.Input,
                ParameterName = "@Member2Name",
                SqlDbType     = SqlDbType.NVarChar,
                SqlValue      = newStandingTeeTimeRequest.Member2Name
            };

            addStandingTeeTimeRequestCommand.Parameters.Add(Member2NameParam);
            SqlParameter Member3NameParam = new SqlParameter()
            {
                Direction     = ParameterDirection.Input,
                ParameterName = "@Member3Name",
                SqlDbType     = SqlDbType.NVarChar,
                SqlValue      = newStandingTeeTimeRequest.Member3Name
            };

            addStandingTeeTimeRequestCommand.Parameters.Add(Member3NameParam);
            SqlParameter Member4NameParam = new SqlParameter()
            {
                Direction     = ParameterDirection.Input,
                ParameterName = "@Member4Name",
                SqlDbType     = SqlDbType.NVarChar,
                SqlValue      = newStandingTeeTimeRequest.Member4Name
            };

            addStandingTeeTimeRequestCommand.Parameters.Add(Member4NameParam);
            SqlParameter StartDateParam = new SqlParameter()
            {
                Direction     = ParameterDirection.Input,
                ParameterName = "@StartDate",
                SqlDbType     = SqlDbType.Date,
                SqlValue      = newStandingTeeTimeRequest.DateStart.Date
            };

            addStandingTeeTimeRequestCommand.Parameters.Add(StartDateParam);
            SqlParameter EndDateParam = new SqlParameter()
            {
                Direction     = ParameterDirection.Input,
                ParameterName = "@EndDate",
                SqlDbType     = SqlDbType.Date,
                SqlValue      = newStandingTeeTimeRequest.DateEnd.Date
            };

            addStandingTeeTimeRequestCommand.Parameters.Add(EndDateParam);
            SqlParameter TeeTimeTimeParam = new SqlParameter()
            {
                Direction     = ParameterDirection.Input,
                ParameterName = "@TeeTimeTime",
                SqlDbType     = SqlDbType.Time,
                SqlValue      = newStandingTeeTimeRequest.TeeTimeTime.TimeOfDay
            };

            addStandingTeeTimeRequestCommand.Parameters.Add(TeeTimeTimeParam);
            SqlParameter EmployeeNameParam = new SqlParameter()
            {
                Direction     = ParameterDirection.Input,
                ParameterName = "@EmployeeName",
                SqlDbType     = SqlDbType.NVarChar,
                SqlValue      = newStandingTeeTimeRequest.EmployeeName
            };

            addStandingTeeTimeRequestCommand.Parameters.Add(EmployeeNameParam);
            SqlParameter RequestedDayOfWeekParam = new SqlParameter()
            {
                Direction     = ParameterDirection.Input,
                ParameterName = "@RequestedDayofWeek",
                SqlDbType     = SqlDbType.Int,
                SqlValue      = newStandingTeeTimeRequest.RequestedDayOfWeek
            };

            addStandingTeeTimeRequestCommand.Parameters.Add(RequestedDayOfWeekParam);
            SqlParameter EmployeeNumberParam = new SqlParameter()
            {
                Direction     = ParameterDirection.Input,
                ParameterName = "@EmployeeNumber",
                SqlDbType     = SqlDbType.Int,
                SqlValue      = newStandingTeeTimeRequest.EmployeeNumber
            };

            addStandingTeeTimeRequestCommand.Parameters.Add(EmployeeNumberParam);
            SqlParameter IsCancelledParam = new SqlParameter()
            {
                Direction     = ParameterDirection.Input,
                ParameterName = "@IsCancelled",
                SqlDbType     = SqlDbType.Bit,
                SqlValue      = newStandingTeeTimeRequest.IsCancelled
            };

            addStandingTeeTimeRequestCommand.Parameters.Add(IsCancelledParam);
            SqlParameter IsApprovedParam = new SqlParameter()
            {
                Direction     = ParameterDirection.Input,
                ParameterName = "@IsApproved",
                SqlDbType     = SqlDbType.Bit,
                SqlValue      = newStandingTeeTimeRequest.IsApproved
            };

            addStandingTeeTimeRequestCommand.Parameters.Add(IsApprovedParam);

            try
            {
                addStandingTeeTimeRequestCommand.ExecuteNonQuery();
            }
            catch (Exception e)
            {
                Console.WriteLine($"addStandingTeeTimeRequest Error - {e}");
                sqlError = true;
            }
            ClubBaistConnection.Close();
            return(sqlError);
        }
Esempio n. 9
0
 public void OnGet()
 {
     Domain.CBS requestDirector = new Domain.CBS(Startup.ConnectionString);
     FoundStandingTeeTime = requestDirector.FindStandingTeeTimeRequest(userManager.GetUserId(User));
     HttpContext.Session.Put(nameof(FoundStandingTeeTime), FoundStandingTeeTime);
 }
        public IActionResult OnPostSubmit()
        {
            Domain.CBS requestDirector = new Domain.CBS(Startup.ConnectionString);
            if (requestDirector.FindStandingTeeTimeRequest(userManager.GetUserId(User)) != null)
            {
                return(Redirect("/MaxStandingTeeTimeRequest"));
            }

            ErrorMessages.Clear();
            bool isError = false;
            var  errors  = from error in ModelState
                           where (error.Key == nameof(SuppliedMemberNumbers) || error.Key == nameof(StartDate) || error.Key == nameof(EndDate)) &&
                           error.Value.ValidationState == Microsoft.AspNetCore.Mvc.ModelBinding.ModelValidationState.Invalid && error.Value.Errors.Any()
                           select error.Value.Errors;

            if (errors.Any())
            {
                ErrorMessages.AddRange(from errorMessage in errors select errorMessage into messages from m in messages select m.ErrorMessage);
                isError = true;
            }

            var signedInMember = userManager.FindByNameAsync(User.Identity.Name).GetAwaiter().GetResult();

            requestDirector = new Domain.CBS(signedInMember.Id, Startup.ConnectionString);

            StartDate = (DateTime)TempData.Peek(nameof(StartDate));
            EndDate   = (DateTime)TempData.Peek(nameof(EndDate));
            StandingTeeTime requestedStandingTeeTime = new StandingTeeTime()
            {
                StartDate = StartDate, EndDate = EndDate, RequestedTime = DateTime.Parse(TempData.Peek("selectedTime").ToString())
            };

            SuppliedMemberNumbers = SuppliedMemberNumbers.Where(s => !string.IsNullOrEmpty(s)).ToArray();

            for (int i = 0; i < SuppliedMemberNumbers.Length; i++)
            {
                SuppliedMemberNumbers[i] = SuppliedMemberNumbers[i].Trim();
            }
            var userIds = (from user in dbContext.Users where SuppliedMemberNumbers.Contains(user.MemberNumber) select user.Id).ToList();

            if (userIds.Count() != SuppliedMemberNumbers.Count())
            {
                ErrorMessages.Add("One or more supplied member numbers do not exist");
                isError = true;
            }

            if (SuppliedMemberNumbers.Contains(signedInMember.MemberNumber))
            {
                ErrorMessages.Add("Do not enter your own member number");
                isError = true;
            }

            if (StartDate.DayOfWeek != EndDate.DayOfWeek)
            {
                ErrorMessages.Add($"Day of week for start date ({StartDate.DayOfWeek}) must match day of week for end date ({EndDate.DayOfWeek})");
                isError = true;
            }

            string currentUser = userManager.GetUserId(User);

            requestedStandingTeeTime.Members     = userIds.Append(currentUser).ToList();
            requestedStandingTeeTime.SubmittedBy = userManager.GetUserId(User);

            if (isError)
            {
                TempData.Put(nameof(ErrorMessages), ErrorMessages);
                return(Redirect(Request.Headers["Referer"]));
            }

            if (!requestDirector.RequestStandingTeeTime(requestedStandingTeeTime, out string message))
            {
                ErrorMessages.Add(message);
                TempData.Put(nameof(ErrorMessages), ErrorMessages);
                return(Redirect(Request.Headers["Referer"]));
            }
            Confirmation = true;
            return(Page());
        }
        public StandingTeeTime FindStandingTeeTimeRequest(int MemberNumber)
        {
            SqlConnection clubbaistConnection = new SqlConnection();

            clubbaistConnection.ConnectionString = Startup.ConnectionString;

            SqlCommand FindStandingTeeTimeRequestCommand = new SqlCommand();

            FindStandingTeeTimeRequestCommand.CommandType = CommandType.StoredProcedure;
            FindStandingTeeTimeRequestCommand.Connection  = clubbaistConnection;
            FindStandingTeeTimeRequestCommand.CommandText = "FindStandingTeeTimeRequest";

            SqlParameter memberNumberParameter = new SqlParameter();

            memberNumberParameter.ParameterName = "@MemberNumber1";
            memberNumberParameter.SqlDbType     = SqlDbType.Int;
            memberNumberParameter.Value         = MemberNumber;

            SqlParameter ReturnCodeParameter = new SqlParameter();

            ReturnCodeParameter.ParameterName = "@ReturnCode";
            ReturnCodeParameter.SqlDbType     = SqlDbType.Int;
            ReturnCodeParameter.Direction     = ParameterDirection.ReturnValue;

            FindStandingTeeTimeRequestCommand.Parameters.Add(memberNumberParameter);
            FindStandingTeeTimeRequestCommand.Parameters.Add(ReturnCodeParameter);

            StandingTeeTime Request = new StandingTeeTime();

            try
            {
                clubbaistConnection.Open();

                SqlDataReader reader;

                reader = FindStandingTeeTimeRequestCommand.ExecuteReader();

                while (reader.Read())
                {
                    Request.StandingTeeTimeID = (int)reader["StandingTeeTimeID"];
                    Request.DayOfWeek         = (DateTime)reader["DayOfWeek"];
                    Request.EndDate           = (DateTime)reader["EndDate"];
                    Request.MemberName1       = reader["MemberName1"].ToString();
                    Request.MemberName2       = reader["MemberName2"].ToString();
                    Request.MemberName3       = reader["MemberName3"].ToString();
                    Request.MemberName4       = reader["MemberName4"].ToString();
                    Request.MemberNumber1     = (int)reader["MemberNumber1"];
                    Request.MemberNumber2     = (int)reader["MemberNumber2"];
                    Request.MemberNumber3     = (int)reader["MemberNumber3"];
                    Request.MemberNumber4     = (int)reader["MemberNumber4"];
                    Request.StartDate         = (DateTime)reader["StartDate"];
                    Request.EndDate           = (DateTime)reader["EndDate"];
                    Request.Time = (TimeSpan)reader["Time"];
                }

                clubbaistConnection.Close();
            }
            catch
            {
            }

            return(Request);
        }
        public bool CreateStandingTeeTimeRequest(StandingTeeTime request)
        {
            bool Success = false;

            SqlConnection clubbaistConnection = new SqlConnection();

            clubbaistConnection.ConnectionString = Startup.ConnectionString;

            SqlCommand CreateStandingTeeTimeRequestCommand = new SqlCommand();

            CreateStandingTeeTimeRequestCommand.CommandType = CommandType.StoredProcedure;
            CreateStandingTeeTimeRequestCommand.Connection  = clubbaistConnection;
            CreateStandingTeeTimeRequestCommand.CommandText = "CreateStandingTeeTimeRequest";

            SqlParameter memberNumber1Parameter = new SqlParameter();

            memberNumber1Parameter.ParameterName = "@MemberNumber1";
            memberNumber1Parameter.SqlDbType     = SqlDbType.Int;
            memberNumber1Parameter.Value         = request.MemberNumber1;

            SqlParameter memberNumber2Parameter = new SqlParameter();

            memberNumber2Parameter.ParameterName = "@MemberNumber2";
            memberNumber2Parameter.SqlDbType     = SqlDbType.Int;
            memberNumber2Parameter.Value         = request.MemberNumber2;

            SqlParameter memberNumber3Parameter = new SqlParameter();

            memberNumber3Parameter.ParameterName = "@MemberNumber3";
            memberNumber3Parameter.SqlDbType     = SqlDbType.Int;
            memberNumber3Parameter.Value         = request.MemberNumber3;

            SqlParameter memberNumber4Parameter = new SqlParameter();

            memberNumber4Parameter.ParameterName = "@MemberNumber4";
            memberNumber4Parameter.SqlDbType     = SqlDbType.Int;
            memberNumber4Parameter.Value         = request.MemberNumber4;

            SqlParameter memberName1Parameter = new SqlParameter();

            memberName1Parameter.ParameterName = "@MemberName1";
            memberName1Parameter.SqlDbType     = SqlDbType.NVarChar;
            memberName1Parameter.Value         = request.MemberName1;

            SqlParameter memberName2Parameter = new SqlParameter();

            memberName2Parameter.ParameterName = "@MemberName2";
            memberName2Parameter.SqlDbType     = SqlDbType.NVarChar;
            memberName2Parameter.Value         = request.MemberName2;

            SqlParameter memberName3Parameter = new SqlParameter();

            memberName3Parameter.ParameterName = "@MemberName3";
            memberName3Parameter.SqlDbType     = SqlDbType.NVarChar;
            memberName3Parameter.Value         = request.MemberName3;

            SqlParameter memberName4Parameter = new SqlParameter();

            memberName4Parameter.ParameterName = "@MemberName4";
            memberName4Parameter.SqlDbType     = SqlDbType.NVarChar;
            memberName4Parameter.Value         = request.MemberName4;

            SqlParameter dayOfWeekParameter = new SqlParameter();

            dayOfWeekParameter.ParameterName = "@DayOfWeek";
            dayOfWeekParameter.SqlDbType     = SqlDbType.DateTime;
            dayOfWeekParameter.Value         = request.DayOfWeek;

            SqlParameter timeParameter = new SqlParameter();

            timeParameter.ParameterName = "@Time";
            timeParameter.SqlDbType     = SqlDbType.Time;
            timeParameter.Value         = request.Time;

            SqlParameter startDateParameter = new SqlParameter();

            startDateParameter.ParameterName = "@StartDate";
            startDateParameter.SqlDbType     = SqlDbType.DateTime;
            startDateParameter.Value         = request.StartDate;

            SqlParameter endDateParameter = new SqlParameter();

            endDateParameter.ParameterName = "@EndDate";
            endDateParameter.SqlDbType     = SqlDbType.DateTime;
            endDateParameter.Value         = request.EndDate;

            SqlParameter ReturnCodeParameter = new SqlParameter();

            ReturnCodeParameter.ParameterName = "@ReturnCode";
            ReturnCodeParameter.SqlDbType     = SqlDbType.Int;
            ReturnCodeParameter.Direction     = ParameterDirection.ReturnValue;

            CreateStandingTeeTimeRequestCommand.Parameters.Add(memberNumber1Parameter);
            CreateStandingTeeTimeRequestCommand.Parameters.Add(memberNumber2Parameter);
            CreateStandingTeeTimeRequestCommand.Parameters.Add(memberNumber3Parameter);
            CreateStandingTeeTimeRequestCommand.Parameters.Add(memberNumber4Parameter);
            CreateStandingTeeTimeRequestCommand.Parameters.Add(memberName1Parameter);
            CreateStandingTeeTimeRequestCommand.Parameters.Add(memberName2Parameter);
            CreateStandingTeeTimeRequestCommand.Parameters.Add(memberName3Parameter);
            CreateStandingTeeTimeRequestCommand.Parameters.Add(memberName4Parameter);
            CreateStandingTeeTimeRequestCommand.Parameters.Add(dayOfWeekParameter);
            CreateStandingTeeTimeRequestCommand.Parameters.Add(timeParameter);
            CreateStandingTeeTimeRequestCommand.Parameters.Add(startDateParameter);
            CreateStandingTeeTimeRequestCommand.Parameters.Add(endDateParameter);
            CreateStandingTeeTimeRequestCommand.Parameters.Add(ReturnCodeParameter);

            try
            {
                clubbaistConnection.Open();
                CreateStandingTeeTimeRequestCommand.ExecuteNonQuery();

                int returnValue = (int)ReturnCodeParameter.Value;
                if (returnValue == 0)
                {
                    Success = true;
                }

                clubbaistConnection.Close();
            }
            catch
            {
                Success = false;
            }


            return(Success);
        }
Esempio n. 13
0
        public bool RequestStandingTeeTime(StandingTeeTime requestedStandingTeeTime, out string message)
        {
            StandingTeeTimeRequests standingTeeTimeManager = new StandingTeeTimeRequests(connectionString);

            return(standingTeeTimeManager.RequestStandingTeeTime(requestedStandingTeeTime, out message));
        }