public string insertQuestions(List <InpecQuestions> inspecQ)
        {
            INSPECTION_QUESTION questionLinq = null;

            try
            {
                using (HotelManagementServerDataContext db = new HotelManagementServerDataContext())
                {
                    foreach (InpecQuestions question in inspecQ)
                    {
                        questionLinq = new INSPECTION_QUESTION()
                        {
                            CATEGORY_ID  = question.CategoryId,
                            QUESTION     = question.Question,
                            REQUIRES_PIC = question.RequiresPicture
                        };

                        db.INSPECTION_QUESTIONs.InsertOnSubmit(questionLinq);
                    }
                    db.SubmitChanges();

                    return("Success Insertion Successful");
                }
            }
            catch (Exception)
            {
                return("Failed Insertion Failed");
            }
        }
        public string insertEvaluationComMembers(List <EvaluationCommitte> evalCommitte)
        {
            EVALUATION_COMM comm = null;

            try
            {
                using (HotelManagementServerDataContext db = new HotelManagementServerDataContext())
                {
                    foreach (EvaluationCommitte person in evalCommitte)
                    {
                        comm = new EVALUATION_COMM()
                        {
                            INSPEC_ID      = person.InspecId,
                            IDENTIFICATION = person.Identification,
                            NAME           = person.Name,
                            SURNAME        = person.Surname,
                            OCCUPATION     = person.Occupation,
                            COMPANY        = person.Oraganisation
                        };
                        db.EVALUATION_COMMs.InsertOnSubmit(comm);
                    }
                    db.SubmitChanges();
                    return("Success Insertion Successful");
                }
            }
            catch (Exception)
            {
                return("Failed Insertion Failed");
            }
        }
        public string updateAccredApplication(CycleApplications application)
        {
            try
            {
                using (HotelManagementServerDataContext db = new HotelManagementServerDataContext())
                {
                    var query = from accredApp in db.CYCLE_APPLICATIONs
                                where accredApp.HOTEL_ID.Equals(Convert.ToInt32(application.HotelId)) &&
                                accredApp.APPLICATION_ID.Equals(Convert.ToInt32(application.ApplicationId))
                                select accredApp;

                    CYCLE_APPLICATION updatedApp = new CYCLE_APPLICATION();
                    updatedApp            = query.Single();
                    updatedApp.APP_STATUS = application.ApplicationStatus;
                    updatedApp.REASON     = application.Reason;
                    db.SubmitChanges();

                    return("Success Update Successful");
                }
            }
            catch (Exception)
            {
                return("Failed Update Failed");
            }
        }
        public string changeInspecResultJason(string inspecId, string result)
        {
            HOTEL_INSPECTION inspec = null;

            try
            {
                using (HotelManagementServerDataContext db = new HotelManagementServerDataContext())
                {
                    var query = from accInspec in db.HOTEL_INSPECTIONs
                                where accInspec.INSPEC_ID.Equals(Convert.ToInt32(inspecId))
                                select accInspec;

                    inspec = query.Single();
                    inspec.INSPEC_RESULT = result;

                    db.SubmitChanges();

                    return("Success Update Successful");
                }
            }
            catch (Exception)
            {
                return("Failed Update Failed");
            }
        }
        public string insertCategories(List <Category> cat)
        {
            CATEGORY catLinq = null;

            try
            {
                using (HotelManagementServerDataContext db = new HotelManagementServerDataContext())
                {
                    foreach (Category category in cat)
                    {
                        catLinq = new CATEGORY()
                        {
                            CATEGORY_NAME = category.CategoryName,
                        };
                        db.CATEGORies.InsertOnSubmit(catLinq);
                    }
                    db.SubmitChanges();

                    return("Success Insertion Successful");
                }
            }
            catch (Exception)
            {
                return("Failed Insertion Failed");
            }
        }
        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 removeAdmin(string id)
        {
            try
            {
                using (HotelManagementServerDataContext db = new HotelManagementServerDataContext())
                {
                    var query = (from acc in db.HOTEL_MANAGERs where acc.MANAGER_ID.Equals(Convert.ToInt32(id)) select acc);
                    if (query.Count() == 1)
                    {
                        HOTEL_MANAGER student = query.Single();

                        if (student.AUTHENTICATION_LEVEL == "A")
                        {
                            student.AUTHENTICATION_LEVEL = "S";
                            db.SubmitChanges();

                            return("Success Update Successful");
                        }
                        else
                        {
                            return("Failed");
                        }
                    }
                    else
                    {
                        return("Failed Error User Not Found");
                    }
                }
            }
            catch (Exception)
            {
                return("Failed Update Failed");
            }
        }
 public Manager updateOfficer(string id, Manager off)
 {
     try
     {
         using (HotelManagementServerDataContext db = new HotelManagementServerDataContext())
         {
             var query = (from acc in db.HOTEL_MANAGERs where acc.MANAGER_ID.Equals(Convert.ToInt32(id)) select acc);
             if (query.Count() == 1)
             {
                 HOTEL_MANAGER acc = query.Single();
                 off = new Manager()
                 {
                     EmployeeNumber = acc.EMPLOYEE_NUM,
                     CityID         = acc.CITY_ID,
                     ContactNumber  = acc.CONTACT_NUM,
                     Email          = acc.EMAIL,
                     Gender         = acc.GENDER,
                     Name           = acc.FULL_NAMES,
                     Surname        = acc.SURNAME,
                     Title          = acc.TITLE,
                 };
                 db.SubmitChanges();
                 return(off);
             }
             else
             {
                 return(null);
             }
         }
     }
     catch (Exception)
     {
         return(null);
     }
 }
        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 OwnersCompany updateCompany(string id, OwnersCompany comp)
 {
     try
     {
         using (HotelManagementServerDataContext db = new HotelManagementServerDataContext())
         {
             var query = (from acc in db.OWNERS_COMPANies where acc.COMP_ID.Equals(Convert.ToInt32(id)) select acc);
             if (query.Count() == 1)
             {
                 OWNERS_COMPANY acc = query.Single();
                 comp = new OwnersCompany()
                 {
                     ContactNum  = acc.CONTACT_NUM,
                     Email       = acc.EMAIL,
                     CompanyName = acc.NAME,
                     RegNum      = acc.REG_NUM
                 };
                 db.SubmitChanges();
                 return(comp);
             }
             else
             {
                 return(null);
             }
         }
     }
     catch (Exception)
     {
         return(null);
     }
 }
 public Owner updateOwner(string id, Owner owner)
 {
     try
     {
         using (HotelManagementServerDataContext db = new HotelManagementServerDataContext())
         {
             var query = (from acc in db.HOTEL_OWNERs where acc.OWNER_ID.Equals(Convert.ToInt32(id)) select acc);
             if (query.Count() == 1)
             {
                 HOTEL_OWNER acc = query.Single();
                 owner = new Owner()
                 {
                     ServiceProviderNumber = acc.SERVICE_PROVIDER_NUM,
                     ContactNumber         = acc.CONTACT_NUM,
                     Email   = acc.EMAIL,
                     Gender  = acc.GENDER,
                     Name    = acc.FULL_NAMES,
                     Surname = acc.SURNAME,
                     Title   = acc.TITLE,
                 };
                 db.SubmitChanges();
                 return(owner);
             }
             else
             {
                 return(null);
             }
         }
     }
     catch (Exception)
     {
         return(null);
     }
 }
        //**************************************************INSPECTION PROCESS**********************************************************************
        public string performInspection(InspectionAdditionalDetails details)
        {
            INSPEC_ADD_DETAIL inspectionLinq = null;

            try
            {
                using (HotelManagementServerDataContext db = new HotelManagementServerDataContext())
                {
                    //foreach (InspectionAdditionalDetails details in inspectionAddDet)
                    //{
                    inspectionLinq = new INSPEC_ADD_DETAIL()
                    {
                        INSPEC_ID         = details.InspecId,
                        QUESTION          = details.Question,
                        CORRECTIVE_ACTION = details.CorrectiveAction,
                        ANSWER            = details.Answer,
                    };
                    db.INSPEC_ADD_DETAILs.InsertOnSubmit(inspectionLinq);
                    db.SubmitChanges();

                    if (details.InspecImages != null)
                    {
                        foreach (ImageFile image in details.InspecImages)
                        {
                            saveImage(image);
                        }
                        db.SubmitChanges();
                    }
                }

                return("Insertion Successfullllllllllllll");
            }
            //}
            catch (Exception e)
            {
                return(e.Message + "hello");
            }
        }
 public void deleteOfficer(string offId)
 {
     try
     {
         using (HotelManagementServerDataContext db = new HotelManagementServerDataContext())
         {
             HOTEL_MANAGER ToDelete = (from s in db.HOTEL_MANAGERs where s.MANAGER_ID.Equals(Convert.ToInt32(offId)) select s).Single();
             db.HOTEL_MANAGERs.DeleteOnSubmit(ToDelete);
             db.SubmitChanges();
         }
     }
     catch (Exception e)
     {
         e.GetBaseException();
     }
 }
 public void deleteCompany(string compId)
 {
     try
     {
         using (HotelManagementServerDataContext db = new HotelManagementServerDataContext())
         {
             OWNERS_COMPANY ToDelete = (from s in db.OWNERS_COMPANies where s.COMP_ID.Equals(Convert.ToInt32(compId)) select s).Single();
             db.OWNERS_COMPANies.DeleteOnSubmit(ToDelete);
             db.SubmitChanges();
         }
     }
     catch (Exception e)
     {
         e.GetBaseException();
     }
 }
 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 string deleteImage(string id)
        {
            try
            {
                using (HotelManagementServerDataContext db = new HotelManagementServerDataContext())
                {
                    INSPEC_IMAGE fileToDelete = (from file in db.INSPEC_IMAGEs where file.IMAGE_ID.Equals(Convert.ToInt32(id)) select file).Single();
                    db.INSPEC_IMAGEs.DeleteOnSubmit(fileToDelete);
                    db.SubmitChanges();

                    return("Success Deletion successful");
                }
            }
            catch (Exception)
            {
                return("Failed Unable to perform deletion");
            }
        }
        public string cancelAccredit(string accommoId)
        {
            try
            {
                using (HotelManagementServerDataContext db = new HotelManagementServerDataContext())
                {
                    HOTEL updateAccred = new HOTEL();
                    updateAccred = (from accommo in db.HOTELs
                                    where accommo.HOTEL_ID.Equals(Convert.ToInt32(accommoId))
                                    select accommo).Single();
                    updateAccred.ACCRED_STATUS = "CANCELLED";
                    db.SubmitChanges();

                    return("Success Cancellation made");
                }
            }
            catch (Exception)
            {
                return("Failed to perform cancellation");
            }
        }
        public string changePassword(string id, string oldPassword, string newPassword)
        {
            try
            {
                using (HotelManagementServerDataContext db = new HotelManagementServerDataContext())
                {
                    var query = (from acc in db.HOTEL_MANAGERs where acc.MANAGER_ID.Equals(Convert.ToInt32(id)) select acc);
                    if (query.Count() == 1)
                    {
                        HOTEL_MANAGER student = query.Single();

                        string oldHashed    = Secrecy.HashPassword(oldPassword);
                        string passwordInDB = student.PASSWORD;

                        if (oldHashed == passwordInDB)
                        {
                            student.PASSWORD = Secrecy.HashPassword(newPassword);
                            db.SubmitChanges();

                            return("Password Changed");
                        }
                        else
                        {
                            return("Incorrect old password");
                        }
                    }
                    else
                    {
                        return("Failed to change password");
                    }
                }
            }



            catch (Exception)
            {
                return("Failed to change password");
            }
        }
Esempio n. 21
0
        public string updateAllCoordinatesInDb()
        {
            try
            {
                using (HotelManagementServerDataContext db = new HotelManagementServerDataContext())
                {
                    List <string>  result   = new List <string>();
                    List <ADDRESS> listAddr = new List <ADDRESS>();

                    var query = from a in db.ADDRESSes select a;
                    listAddr = query.ToList();

                    foreach (ADDRESS add in listAddr)
                    {
                        if (add.LATITUDE == null || add.LONGTUDE == null)
                        {
                            result = getLatLong(add.STREET, add.TOWN, add.CITY);
                            //Equate the ff to the result of the above
                            string lng = "";
                            string lat = "";
                            if (result.Count() == 2)
                            {
                                lat = result[0];
                                lng = result[1];
                            }
                            add.LONGTUDE = lng;
                            add.LATITUDE = lat;
                        }
                    }
                    db.SubmitChanges();
                }

                return("Success All coordinates updated");
            }
            catch (Exception)
            {
                return("Failed");
            }
        }
        public string createInspection(HotelInspection inspection)
        {
            HOTEL_INSPECTION inspec = null;

            //ACCRED_APPLICATION appl = null;
            try
            {
                using (HotelManagementServerDataContext db = new HotelManagementServerDataContext())
                {
                    /*var query = from application in db.ACCRED_APPLICATIONs
                     *          where application.ACCOMMO_ID.Equals(inspection.AccommoId) &&
                     *              application.APPLICATION_ID.Equals(inspection.ApplicationId)
                     *          select application;
                     *
                     * appl = new ACCRED_APPLICATION();
                     * appl = query.Single();
                     *
                     * appl.APP_STATUS = "APPROVED";
                     * appl.REASON = "CRITERIA MET";
                     * db.SubmitChanges();*/

                    inspec = new HOTEL_INSPECTION()
                    {
                        MANAGER_ID     = inspection.OfficerId,
                        APPLICATION_ID = inspection.ApplicationId,
                        INSPEC_DATE    = DateTime.Now,
                        INSPEC_RESULT  = "PENDING"
                    };
                    db.HOTEL_INSPECTIONs.InsertOnSubmit(inspec);
                    db.SubmitChanges();

                    return("Success Insertion Successful");
                }
            }
            catch (Exception)
            {
                return("Failed Insertion Failed");
            }
        }
        public string accreditAccommo(string accommoId)
        {
            try
            {
                using (HotelManagementServerDataContext db = new HotelManagementServerDataContext())
                {
                    HOTEL updateAccred = (from accommo in db.HOTELs
                                          where accommo.HOTEL_ID.Equals(Convert.ToInt32(accommoId))
                                          select accommo).Single();
                    updateAccred.ACCRED_STATUS      = "ACCREDITED";
                    updateAccred.ACCRED_START_DATE  = Convert.ToDateTime(DateTime.Now.AddYears(1).Year.ToString() + "-01-01");
                    updateAccred.ACCRED_EXPIRY_DATE = Convert.ToDateTime(AccreditationDuration.computeDuration());
                    db.SubmitChanges();

                    return("Success Accreditation made");
                }
            }
            catch (Exception)
            {
                return("Failed to perform accreditation");
            }
        }
Esempio n. 24
0
        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);
            }
        }
Esempio n. 25
0
        public void makeRating(ClientHotelRatings ratingMade)
        {
            try
            {
                using (HotelManagementServerDataContext db = new HotelManagementServerDataContext())
                {
                    var query = (from rating in db.CLIENT_HOTEL_RATINGs
                                 where rating.CLIENT_ID.Equals(Convert.ToInt32(ratingMade.ClientID)) && rating.HOTEL_ID.Equals(Convert.ToInt32(ratingMade.HotelID))
                                 select rating);

                    int count = query.Count();
                    if (count == 0)
                    {
                        CLIENT_HOTEL_RATING AccommoRating = new CLIENT_HOTEL_RATING()
                        {
                            HOTEL_ID     = ratingMade.HotelID,
                            CLIENT_ID    = ratingMade.ClientID,
                            RATING_VALUE = ratingMade.RatingValue
                        };

                        db.CLIENT_HOTEL_RATINGs.InsertOnSubmit(AccommoRating);
                        db.SubmitChanges();
                    }
                    if (count == 1)
                    {
                        CLIENT_HOTEL_RATING update = new CLIENT_HOTEL_RATING();
                        update = query.Single();

                        update.RATING_VALUE = ratingMade.RatingValue;
                    }
                }
            }
            catch (Exception e)
            {
                e.GetBaseException();
            }
        }
        public string RegisterOwner(Owner owner)
        {
            using (HotelManagementServerDataContext db = new HotelManagementServerDataContext())
            {
                HOTEL_OWNER ownerLinq = null;

                try
                {
                    int ownerLinqTest = (from uOwner in db.HOTEL_OWNERs where uOwner.EMAIL.Equals(owner.Email) select uOwner).Count();
                    if (ownerLinqTest == 0)
                    {
                        ownerLinq.OWNER_ID             = Convert.ToInt32(owner.ID);
                        ownerLinq.SERVICE_PROVIDER_NUM = Convert.ToInt32(owner.ServiceProviderNumber);
                        ownerLinq.FULL_NAMES           = owner.Name;
                        ownerLinq.SURNAME              = owner.Surname;
                        ownerLinq.GENDER               = owner.Gender;
                        ownerLinq.EMAIL                = owner.Email;
                        ownerLinq.CONTACT_NUM          = owner.ContactNumber;
                        ownerLinq.PASSWORD             = owner.Password;
                        ownerLinq.AUTHENTICATION_LEVEL = Convert.ToString(owner.AuthenticationLevel);
                        ownerLinq.TITLE                = Convert.ToString(owner.Title);
                        db.HOTEL_OWNERs.InsertOnSubmit(ownerLinq);
                        db.SubmitChanges();
                        return("Success Regristration Successful" + " Your Service Provider Number:" + owner.ServiceProviderNumber);
                    }
                    else if (ownerLinqTest != 0)
                    {
                        return("Failed Username already exists");
                    }
                }
                catch (Exception)
                {
                    return("Failed Registration failed, contact admin");
                }
            }
            return("Failed Registration failed, contact admin");
        }
        public string assignAccommodations(OfficerHandlesAccommo assignment)
        {
            try
            {
                using (HotelManagementServerDataContext db = new HotelManagementServerDataContext())
                {
                    MANAGER_HANDLES_HOTEL insert = new MANAGER_HANDLES_HOTEL()
                    {
                        HOTEL_ID      = assignment.AccommoID,
                        MANAGER_ID    = assignment.OfficerID,
                        DATE_ASSIGNED = Convert.ToDateTime(assignment.AssignDate)
                    };

                    db.MANAGER_HANDLES_HOTELs.InsertOnSubmit(insert);
                    db.SubmitChanges();

                    return("Success");
                }
            }
            catch (Exception e)
            {
                return("Failed " + e.Message);
            }
        }