public IHttpActionResult GetTransaction_TableByUser(int id) { Transaction_Table transaction_Table = db.Transaction_Table.Where(x => x.User_Id == id && (x.Status == "Volunteer Requested" || x.Status == "Active" || x.Status == "Driver Requested")).FirstOrDefault(); if (transaction_Table == null) { return(NotFound()); } DTO_Transaction_Table dtt = new DTO_Transaction_Table(); transaction_Table.ConvertToDTO(dtt); if (transaction_Table.User_Id != null) { User user = db.Users.Where(x => x.User_Id == dtt.User_Id).Single(); dtt.User_Name = user.F_Name + " " + user.L_Name; dtt.User_Mobile_Number = user.Mobile_Number; } if (transaction_Table.Volunteer_Id != null) { Volunteer volunteer = db.Volunteers.Where(x => x.Volunteer_Id == dtt.Volunteer_Id).Single(); dtt.Volunteer_Name = volunteer.F_Name + " " + volunteer.L_Name; dtt.Volunteer_Mobile = volunteer.Mobile_Number; } if (transaction_Table.Driver_Id != null) { Driver driver = db.Drivers.Where(x => x.Driver_Id == dtt.Driver_Id).Single(); dtt.Driver_Name = driver.F_Name + " " + driver.L_Name; dtt.Driver_Mobile = driver.Mobile_Number; } return(Ok(dtt)); }
public IHttpActionResult GetTransaction_Table(int id) { Transaction_Table transaction_Table = db.Transaction_Table.Find(id); if (transaction_Table == null) { return(NotFound()); } DTO_Transaction_Table dtt = new DTO_Transaction_Table(); transaction_Table.ConvertToDTO(dtt); if (transaction_Table.User_Id != null) { User user = db.Users.Where(x => x.User_Id == dtt.User_Id).Single(); dtt.User_Name = user.F_Name + " " + user.L_Name; dtt.User_Mobile_Number = user.Mobile_Number; } if (transaction_Table.Volunteer_Id != null) { Volunteer volunteer = db.Volunteers.Where(x => x.Volunteer_Id == dtt.Volunteer_Id).Single(); dtt.Volunteer_Name = volunteer.F_Name + " " + volunteer.L_Name; dtt.Volunteer_Mobile = volunteer.Mobile_Number; } if (transaction_Table.Driver_Id != null) { Driver driver = db.Drivers.Where(x => x.Driver_Id == dtt.Driver_Id).Single(); dtt.Driver_Name = driver.F_Name + " " + driver.L_Name; dtt.Driver_Mobile = driver.Mobile_Number; } return(Ok(dtt)); }