Esempio n. 1
0
        public RequestRemarks CancelRequest(PostRequest cancelRequest)
        {
            var objReturn = new RequestRemarks();

            if (IsRandomCodeValid(cancelRequest.trip_id, cancelRequest.random))
            {
                var eecEmployee  = new EECEmployee();
                var employeeInfo = eecEmployee.SearchOnDirectory(cancelRequest.emp_id);
                var info         = employeeInfo.Count != 0 ? employeeInfo[0] : null;

                using (var con = new MySqlConnection(ConnectionHelper.ServicesConnection()))
                {
                    con.Open();
                    var cmd = new MySqlCommand("DELETE FROM seat WHERE random=@random AND trip_id=@trip_id", con);
                    cmd.Parameters.AddWithValue("@trip_id", cancelRequest.trip_id);
                    cmd.Parameters.AddWithValue("@random", cancelRequest.random);

                    if (cmd.ExecuteNonQuery() > 0)
                    {
                        objReturn = new RequestRemarks
                        {
                            remarks = "You have cancelled your reserved seat!",
                            subject = "Cancelled"
                        };

                        AppendLog(info.e_Mail.Split('@')[0], " cancelled ", cancelRequest.trip_id + " reservation");
                    }
                }
            }

            else
            {
                objReturn = new RequestRemarks
                {
                    remarks = "Trip not found.",
                    subject = "Notice"
                };
            }

            return(objReturn);
        }
Esempio n. 2
0
        public List <EECEmployee> search_on_directory(string keyWord)
        {
            var eecEmployee = new EECEmployee();

            return(eecEmployee.SearchOnDirectory(keyWord));
        }
Esempio n. 3
0
        public RequestRemarks CreateUpdateRequest(PostRequest newRequest)
        {
            var objReturn = new RequestRemarks();

            var eecEmployee  = new EECEmployee();
            var employeeInfo = eecEmployee.SearchOnDirectory(newRequest.emp_id);
            var info         = employeeInfo.Count != 0 ? employeeInfo[0] : null;

            if (info != null)
            {
                if (IsTripValid(newRequest.trip_id))
                {
                    if (newRequest.seat_no >= 0 && newRequest.seat_no <= 6)
                    {
                        if (!IsSeatAvailable(newRequest.trip_id, newRequest.seat_no))
                        {
                            objReturn = new RequestRemarks
                            {
                                remarks = "Seat selected is no longer available!",
                                subject = "Already Taken"
                            };
                        }

                        else
                        {
                            if (IsUpdateSeat(info.emp_ID, newRequest.trip_id, newRequest.seat_no))
                            {
                                if (IsRandomCodeValid(newRequest.trip_id, newRequest.random))
                                {
                                    using (var con = new MySqlConnection(ConnectionHelper.ServicesConnection()))
                                    {
                                        con.Open();
                                        var cmd = new MySqlCommand("UPDATE seat SET seat=@seat,date_submit=@date_submit WHERE pax_id=@pax_id AND trip_id=@trip_id", con);
                                        cmd.Parameters.AddWithValue("@seat", newRequest.seat_no);
                                        cmd.Parameters.AddWithValue("@date_submit", DateTime.Now);
                                        cmd.Parameters.AddWithValue("@trip_id", newRequest.trip_id);
                                        cmd.Parameters.AddWithValue("@pax_id", info.emp_ID);

                                        if (cmd.ExecuteNonQuery() > 0)
                                        {
                                            objReturn = new RequestRemarks
                                            {
                                                remarks = "You have updated your reserved seat!",
                                                subject = "Updated"
                                            };

                                            AppendLog(info.e_Mail.Split('@')[0], " updated to " + newRequest.seat_no + " on ", newRequest.trip_id);
                                        }
                                    }
                                }

                                else
                                {
                                    objReturn = new RequestRemarks
                                    {
                                        remarks = "Trip not found.",
                                        subject = "Notice"
                                    };
                                }
                            }

                            else
                            {
                                var tripDetails = new TripDetails();
                                var details     = tripDetails.GetTripDetails(newRequest.trip_id);
                                using (var con = new MySqlConnection(ConnectionHelper.ServicesConnection()))
                                {
                                    con.Open();
                                    var cmd = new MySqlCommand("INSERT INTO seat ( trip_id, trip, pax_name, gender, pax_email, pax_id, seat, cost_center, ip, date_submit, code, random) VALUES(@trip_id,@trip,@pax_name,@gender,@pax_email,@pax_id,@seat,@cost_center,@ip,@date_submit,@code,@random)", con);
                                    cmd.Parameters.AddWithValue("@trip_id", newRequest.trip_id);
                                    cmd.Parameters.AddWithValue("@trip", details.trip_date);
                                    cmd.Parameters.AddWithValue("@pax_name", info.employee_Name_English);
                                    cmd.Parameters.AddWithValue("@gender", info.gender);
                                    cmd.Parameters.AddWithValue("@pax_email", info.e_Mail);
                                    cmd.Parameters.AddWithValue("@pax_id", info.emp_ID);
                                    cmd.Parameters.AddWithValue("@seat", newRequest.seat_no);
                                    cmd.Parameters.AddWithValue("@cost_center", info.cost_Center);
                                    cmd.Parameters.AddWithValue("@ip", "EEC Mobility");
                                    cmd.Parameters.AddWithValue("@date_submit", DateTime.Now);
                                    cmd.Parameters.AddWithValue("@code", 1);
                                    cmd.Parameters.AddWithValue("@random", RandomizeHelper.GenerateRandomString());

                                    if (cmd.ExecuteNonQuery() > 0)
                                    {
                                        objReturn = new RequestRemarks
                                        {
                                            remarks = "You have reserved a seat!",
                                            subject = "Reserved"
                                        };

                                        AppendLog(info.e_Mail.Split('@')[0], " reserved " + newRequest.seat_no + " on ", newRequest.trip_id);
                                    }
                                }
                            }
                        }
                    }

                    else
                    {
                        objReturn = new RequestRemarks
                        {
                            remarks = "Seat not found.",
                            subject = "Notice"
                        };
                    }
                }

                else
                {
                    objReturn = new RequestRemarks
                    {
                        remarks = "Trip not found.",
                        subject = "Notice"
                    };
                }
            }

            else
            {
                objReturn = new RequestRemarks
                {
                    remarks = "Request should be initiated by an EEC Employee.",
                    subject = "Notice"
                };
            }

            return(objReturn);
        }