private RoomResultReservationOrderViewModel CreateReservationOrder(RoomReservationOrderViewModel order) { var reservationResult = new RoomResultReservationOrderViewModel(); try { string insertGuestInfo = string.Format("INSERT INTO tblt_resheader VALUES({0},'{1}','{2}','{3}','{4}' ,'{5}',{6},{7},'{8}','{9}',{10},'{11}','{12}')", order.ResNo, order.Title, order.FirstName, order.LastName, order.Address, order.ContactNo, 1, 1, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), 1, order.CheckInDate.ToString("yyyy-MM-dd HH:mm:ss"), order.CheckInDate.ToString("yyyy-MM-dd HH:mm:ss")); int val = DbConnetClass.setData(insertGuestInfo); if (val > 0) { order.selectedRooms.ForEach(t => { string insertRoomReseDetails = string.Format("INSERT INTO tblt_resdet VALUES({0},{1},{2},'{3}',{4} ,{5},'{6}','{7}',{8})", order.ResNo, t.RoomId, t.RoomRate, "LKR", 1, 1, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), 1); DbConnetClass.setData(insertRoomReseDetails); }); reservationResult.IsSuccess = true; reservationResult.Message = "Reservation is saved successfully"; } } catch (Exception ex) { } return(reservationResult); }
public RoomResultReservationOrderViewModel SaveReservationOrder(RoomReservationOrderViewModel order) { var result = new RoomResultReservationOrderViewModel(); if (GetReservationById(order.ResNo)) { result = UpdateReservationOrder(order); } else { result = CreateReservationOrder(order); } return(result); }
private RoomResultReservationOrderViewModel UpdateReservationOrder(RoomReservationOrderViewModel order) { var reservationResult = new RoomResultReservationOrderViewModel(); try { string insertGuestInfo = string.Format("UPDATE tblt_resheader SET Cus_title='{0}',Cus_FName='{1}',Cus_LName='{2}',Cus_Addr='{3}',Cus_Cont='{4}' ,updated_by={5},updated_on={6},isactive={7} WHERE Res_no = '" + order.ResNo + "'", order.Title, order.FirstName, order.LastName, order.Address, order.ContactNo, 1, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), 1); int val = DbConnetClass.setData(insertGuestInfo); if (val > 0) { order.roolListVm.ForEach(t => { string getOrderDetails = "SELECT * FROM tblt_resdet WHERE Res_no = '" + order.ResNo + "' AND Room_no = '" + t.RoomId + "'"; MySqlDataReader orderReader = DbConnetClass.getData(getOrderDetails); if (!orderReader.HasRows) { string insertRoomReseDetails = string.Format("INSERT INTO tblt_resdet VALUES({0},{1},{2},'{3}',{4} ,{5},'{6}','{7}',{8})", order.ResNo, t.RoomId, t.RoomRate, "LKR", 1, 1, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), 1); DbConnetClass.setData(insertRoomReseDetails); } else { if (t.IsRemoved) { string deleteRoomReserved = "DELETE FROM tblt_resdet WHERE WHERE Res_no = '" + order.ResNo + "' AND Room_no = '" + t.RoomId + "'"; DbConnetClass.setData(deleteRoomReserved); } } }); reservationResult.IsSuccess = true; reservationResult.Message = "Reservation is saved successfully"; } } catch (Exception ex) { } return(reservationResult); }