public string RegisterManager(Manager manager) { using (HotelManagementServerDataContext db = new HotelManagementServerDataContext()) { HOTEL_MANAGER officerLinq = null; try { int officerLinqTest = (from uOfficer in db.HOTEL_MANAGERs where uOfficer.EMAIL.Equals(manager.Email) select uOfficer).Count(); if (officerLinqTest == 0) { officerLinq = ConvertToLinq.ConvertOfficerToLinqObject(manager); db.HOTEL_MANAGERs.InsertOnSubmit(officerLinq); db.SubmitChanges(); return("Success Regristration Successful"); } else if (officerLinqTest != 0) { return("Failed Username already exists"); } } catch (Exception) { return("Failed Registration failed, contact admin"); } } return("Failed Registration failed, contact admin"); }
public string RegisterClient(Client client) { //Using the using keyword ensures that the connection is closed automatically using (HotelManagementServerDataContext db = new HotelManagementServerDataContext()) { CLIENT clientLinq = null; try { int clientLinqTest = (from uStud in db.CLIENTs where uStud.EMAIL.Equals(client.Email) select uStud).Count(); if (clientLinqTest == 0) { clientLinq = ConvertToLinq.ConvertStudentToLinqObject(client); db.CLIENTs.InsertOnSubmit(clientLinq); db.SubmitChanges(); return("Success Regristration Successful"); } else if (clientLinqTest != 0) { return("Failed Username already exists"); } } catch (Exception e) { return(e.GetBaseException().ToString());//"Registration failed, contact admin"; } } return("Why does this keeps happening???"); }
public string saveImage(ImageFile image) { try { using (HotelManagementServerDataContext db = new HotelManagementServerDataContext()) { INSPEC_IMAGE fileToSave = ConvertToLinq.ConvertInspecImageToLinq(image); db.INSPEC_IMAGEs.InsertOnSubmit(fileToSave); db.SubmitChanges(); } return("Success File Uploaded"); } catch (Exception) { return("Failed Upload Failed"); } }
public int applyForAccred(CycleApplications application) { try { using (HotelManagementServerDataContext db = new HotelManagementServerDataContext()) { CYCLE_APPLICATION applicationToInsert = ConvertToLinq.ConvertAccredApplyToLinq(application); db.CYCLE_APPLICATIONs.InsertOnSubmit(applicationToInsert); db.SubmitChanges(); return(applicationToInsert.APPLICATION_ID); } } catch (Exception) { return(-1); } }
public string insertCompany(OwnersCompany comp) { try { using (HotelManagementServerDataContext db = new HotelManagementServerDataContext()) { OWNERS_COMPANY companyLinq = ConvertToLinq.ConvertCompanyToLinq(comp); db.OWNERS_COMPANies.InsertOnSubmit(companyLinq); db.SubmitChanges(); return("Success Adding company was successful"); } } catch (Exception) { return("Failed Adding company failed, contact admin"); } }
public int insertAddress(Address addr) { try { ADDRESS addrLnq = null; using (HotelManagementServerDataContext db = new HotelManagementServerDataContext()) { addrLnq = new ADDRESS(); addrLnq = ConvertToLinq.ConvertAddressToLinq(addr); db.ADDRESSes.InsertOnSubmit(addrLnq); db.SubmitChanges(); int addrssID = addrLnq.ADDRESS_ID; return(addrssID);// "Adding Address was successful"; } } catch (Exception) { return(-1); } }