public IHttpActionResult CreateRoom([FromBody] Request request)
        {
            response = new Response();

            int result = 0;

            try
            {
                using (var model = new HOSTING_MANAGEREntities())
                {
                    model.Configuration.ProxyCreationEnabled = false;
                    if (request.Session > 0 && request.User > 0 && request.Data != null)
                    {
                        var room = JsonConvert.DeserializeObject <ROOM>(request.Data.ToString());

                        if (room != null && !string.IsNullOrEmpty(room.DESCRIPTION))
                        {
                            ObjectParameter @ROOM_ID = new ObjectParameter("@ROOM_ID", typeof(Int32));
                            model.SP_CREATE_ROOM(room.HOTEL_ID, room.NUMBER, room.FLOOR, room.ROOM_TYPE_ID, room.DESCRIPTION, room.PRICE, @ROOM_ID);

                            if (!string.IsNullOrEmpty(@ROOM_ID.Value.ToString()))
                            {
                                result = Convert.ToInt32(@ROOM_ID.Value.ToString());
                            }
                        }
                    }
                    if (result == 0)
                    {
                        response.CodeError = 200;
                        response.Message   = "OK";
                        response.Data      = result;
                    }
                    else
                    {
                        response.CodeError = 100;
                        response.Message   = "No se logro insertar el log";
                        response.Data      = false;
                    }
                }
            }
            catch (Exception ex)
            {
                response.CodeError = 300;
                response.Message   = "Unexpected Error" + ex.ToString();
                response.Data      = false;
            }
            return(Ok(response));
        }
        public IHttpActionResult CreateTax([FromBody] Request request)
        {
            response = new Response();

            int result = 0;

            try
            {
                using (var model = new HOSTING_MANAGEREntities())
                {
                    model.Configuration.ProxyCreationEnabled = false;
                    if (request.Session > 0 && request.User > 0 && request.Data != null)
                    {
                        var room_tax = JsonConvert.DeserializeObject <ROOM_TAX>(request.Data.ToString());

                        if (room_tax != null && room_tax.TAX != null)
                        {
                            ObjectParameter @TAX_ID = new ObjectParameter("@TAX_ID", typeof(Int32));
                            model.SP_CREATE_TAX(room_tax.ROOM_ID, room_tax.TAX.NAME, room_tax.TAX.DESCRIPTION, room_tax.TAX.PERCENTAGE, room_tax.TAX.VALUE, @TAX_ID);

                            if (!string.IsNullOrEmpty(@TAX_ID.Value.ToString()))
                            {
                                result = Convert.ToInt32(@TAX_ID.Value.ToString());
                            }
                        }
                    }
                    if (result == 0)
                    {
                        response.CodeError = 200;
                        response.Message   = "OK";
                        response.Data      = result;
                    }
                    else
                    {
                        response.CodeError = 100;
                        response.Message   = "No se logro insertar el log";
                        response.Data      = false;
                    }
                }
            }
            catch (Exception ex)
            {
                response.CodeError = 300;
                response.Message   = "Unexpected Error" + ex.ToString();
                response.Data      = false;
            }
            return(Ok(response));
        }
        public IHttpActionResult CreateHotel([FromBody] Request request)
        {
            response = new Response();

            int result = 0;

            try
            {
                using (var model = new HOSTING_MANAGEREntities())
                {
                    model.Configuration.ProxyCreationEnabled = false;
                    if (request.Session > 0 && request.User > 0 && request.Data != null)
                    {
                        var hotel = JsonConvert.DeserializeObject <HOTEL>(request.Data.ToString());

                        if (hotel != null && !string.IsNullOrEmpty(hotel.NAME))
                        {
                            ObjectParameter @HOTEL_ID = new ObjectParameter("HOTEL_ID", typeof(Int32));
                            model.SP_CREATE_HOTEL(hotel.LOCATION_ID, hotel.REFERENCE, hotel.NAME, hotel.CAPACITY, hotel.DESCRIPTION, request.User, @HOTEL_ID);

                            if (!string.IsNullOrEmpty(@HOTEL_ID.Value.ToString()))
                            {
                                result = Convert.ToInt32(@HOTEL_ID.Value.ToString());
                            }
                        }
                    }
                    if (result == 0)
                    {
                        response.CodeError = 200;
                        response.Message   = "OK";
                        response.Data      = result;
                    }
                    else
                    {
                        response.CodeError = 100;
                        response.Message   = "No se logro insertar el log";
                        response.Data      = false;
                    }
                }
            }
            catch (Exception ex)
            {
                response.CodeError = 300;
                response.Message   = "Unexpected Error" + ex.ToString();
                response.Data      = false;
            }
            return(Ok(response));
        }
示例#4
0
 public bool ValidateToken(string token)
 {
     try
     {
         using (var model = new HOSTING_MANAGEREntities())
         {
             var result = model.SP_VALIDATE_TOKEN(token).FirstOrDefault();
             if (result.Value > 0)
             {
                 return(true);
             }
         }
     }
     catch (Exception ex)
     {
     }
     return(false);
 }
示例#5
0
 public static ObjectResult <SP_GET_HOTELES_Result> GetListHoteles()
 {
     try
     {
         using (var model = new HOSTING_MANAGEREntities())
         {
             model.Configuration.ProxyCreationEnabled = false;
             var result = model.SP_GET_HOTELES();
             if (result != null && result.Count() > 0)
             {
                 return(result);
             }
         }
     }
     catch (Exception ex)
     {
     }
     return(null);
 }
示例#6
0
        public static int InsertBooking(RIDER rider)
        {
            try
            {
                using (var model = new HOSTING_MANAGEREntities())
                {
                    model.Configuration.ProxyCreationEnabled = false;
                    if (rider != null && !string.IsNullOrEmpty(rider.NUMBER_DOCUMENT))
                    {
                        ObjectParameter @RIDER_ID = new ObjectParameter("RIDER_ID", typeof(Int32));
                        model.SP_CREATE_RIDER(rider.DOCUMENT_TYPE_ID, rider.NUMBER_DOCUMENT, rider.NAME,
                                              rider.BIRTHDAY_DATE, rider.GENDER, rider.EMAIL, rider.PHONE, rider.EMERGENCY_NAME,
                                              rider.EMERGENCY_PHONE, @RIDER_ID);

                        if (!string.IsNullOrEmpty(@RIDER_ID.Value.ToString()))
                        {
                            var result = Convert.ToInt32(@RIDER_ID.Value.ToString());

                            if (rider.BOOKING != null)
                            {
                                var             booking     = rider.BOOKING.FirstOrDefault();
                                ObjectParameter @BOOKING_ID = new ObjectParameter("BOOKING_ID", typeof(Int32));
                                string          codeBooking = Utilities.GenerateCodeBooking();
                                model.SP_CREATE_BOOKING(booking.ROOM_ID, result, codeBooking, booking.CHEK_IN, booking.CHEK_OUNT, booking.NUMBER_PEOPLE, booking.DESCRIPTION, booking.STATE_BOOKING_ID, @BOOKING_ID);

                                if (!string.IsNullOrEmpty(@BOOKING_ID.Value.ToString()))
                                {
                                    return(Convert.ToInt32(@BOOKING_ID.Value.ToString()));
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
            }
            return(0);
        }
示例#7
0
        public IHttpActionResult GetBookings([FromBody] Request request)
        {
            response      = new Response();
            response.Data = null;

            try
            {
                using (var model = new HOSTING_MANAGEREntities())
                {
                    model.Configuration.ProxyCreationEnabled = false;
                    if (request.Session > 0 && request.User > 0)
                    {
                        var result = model.SP_GET_BOOKINGS(request.User);
                        if (result != null)
                        {
                            response.Data = result;
                        }
                    }
                    if (response.Data != null)
                    {
                        response.CodeError = 200;
                        response.Message   = "OK";
                    }
                    else
                    {
                        response.CodeError = 100;
                        response.Message   = "No se logro insertar el log";
                        response.Data      = false;
                    }
                }
            }
            catch (Exception ex)
            {
                response.CodeError = 300;
                response.Message   = "Unexpected Error" + ex.ToString();
                response.Data      = false;
            }
            return(Ok(response));
        }
        public IHttpActionResult CreateBooking([FromBody] Request request)
        {
            response = new Response();

            int result = 0;

            try
            {
                using (var model = new HOSTING_MANAGEREntities())
                {
                    model.Configuration.ProxyCreationEnabled = false;
                    if (request.Session > 0 && request.User > 0 && request.Data != null)
                    {
                        result = DbConection.InsertBooking(JsonConvert.DeserializeObject <RIDER>(request.Data.ToString()));
                    }
                    if (result == 0)
                    {
                        response.CodeError = 200;
                        response.Message   = "OK";
                        response.Data      = result;
                    }
                    else
                    {
                        response.CodeError = 100;
                        response.Message   = "No se logro insertar el log";
                        response.Data      = false;
                    }
                }
            }
            catch (Exception ex)
            {
                response.CodeError = 300;
                response.Message   = "Unexpected Error" + ex.ToString();
                response.Data      = false;
            }
            return(Ok(response));
        }
示例#9
0
        public IHttpActionResult Authenticate([FromBody] RequestAuthentication request)
        {
            var response = new ResponseAuthentication();

            string token = "";

            int idSession = 0;

            int idUser = 0;

            try
            {
                if (request != null && !string.IsNullOrEmpty(request.Email) && !string.IsNullOrEmpty(request.Password))
                {
                    using (var model = new HOSTING_MANAGEREntities())
                    {
                        model.Configuration.ProxyCreationEnabled = false;

                        var user = model.SP_VALIDATE_TRAVEL_AGENT(request.Email, request.Password).FirstOrDefault();

                        if (user != null)
                        {
                            var login = model.SP_VALIDATE_LOGIN_API(user.TRAVEL_AGENT_ID).FirstOrDefault();

                            if (login != null)
                            {
                                token     = login.TOKEN;
                                idSession = login.API_LOGIN_LOG_ID;
                                idUser    = user.TRAVEL_AGENT_ID;
                            }
                            else
                            {
                                token = Utilities.GenerateToken();
                                if (!string.IsNullOrEmpty(token))
                                {
                                    ObjectParameter @sessionId = new ObjectParameter("LOGINID", typeof(Int32));

                                    model.SP_CREATE_LOGIN_API(user.TRAVEL_AGENT_ID, Utilities.SumDate(), token, @sessionId);

                                    if (@sessionId != null && @sessionId.Value != null)
                                    {
                                        idSession = Convert.ToInt32(@sessionId.Value.ToString());
                                        idUser    = user.TRAVEL_AGENT_ID;
                                    }
                                }
                            }
                        }
                    }

                    if (idSession > 0)
                    {
                        response.CodeError = 200;
                        response.Message   = "OK";
                        response.Token     = token;
                        response.Session   = idSession;
                        response.User      = idUser;
                    }
                    else
                    {
                        response.CodeError = 100;
                        response.Message   = "El usuario no existe o se encuentra desactivado";
                    }
                }
                else
                {
                    response.CodeError = 400;
                    response.Message   = "Informacion incorrecta";
                }
            }
            catch (Exception ex)
            {
                response.CodeError = 300;
                response.Message   = "Unexpected Error" + ex.ToString();
            }
            return(Ok(response));
        }