Exemple #1
0
        public bool removeSpecialization(int Id)
        {
            Specialization specialization = DataSource.Specializations.FirstOrDefault(s => s.ID == Id);

            if (specialization == null)
            {
                throw new Exception("Student with the same id already exists...");
            }

            return(DataSource.Specializations.Remove(specialization));
        }
Exemple #2
0
 private void ExceptionsOfSpecialization(Specialization newSpecialization)
 {
     if (newSpecialization.MaxHourSalary < newSpecialization.MinHourSalary)
     {
         throw new Exception("המינימום לשעה חייב להיות פחות מהמקסימום");
     }
     if ((newSpecialization.ID >= 100000000 || newSpecialization.ID < 10000000) && newSpecialization.ID != 0)
     {
         throw new Exception("צריך מספר של 8 ספרות");
     }
 }
Exemple #3
0
 public static Faculty Get(Specialization specialization)
 {
     try
     {
         return(GetList().Where(x => x.Id == specialization.Faculty_Id).ToList().First());
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemple #4
0
 public void removeSpecialization(Specialization oldSpecialization)
 {
     foreach (Specialization element in DataSource.specialization)
     {
         if (element == oldSpecialization)
         {
             DataSource.specialization.Remove(oldSpecialization);
         }
     }
     throw new NotImplementedException();
 }
        public void UpdateSpecialization(Specialization specialization)
        {
            LoadDataSpecialization();
            XElement specializationElement = (from p in specializationRoot.Elements()
                                              where Convert.ToInt32(p.Element("SpecialNum").Value) == specialization.SpecialNum
                                              select p).FirstOrDefault();

            specializationElement.Element("Field").Value = Convert.ToString(specialization.Field);
            specializationElement.Element("Tarif").Element("TariffMin").Value = Convert.ToString(specialization.TariffMin);
            specializationElement.Element("Tarif").Element("TariffMax").Value = Convert.ToString(specialization.TariffMax);
            specializationRoot.Save(specializationPath);
        }
Exemple #6
0
        public void updateSpecialization(Specialization newJob)
        {
            Specialization s = getSpecialization(newJob.number);

            if (s == null)
            {
                throw new Exception("Specialization doesn't exist");
            }

            DataSources.specializationList.Remove(s);
            DataSources.specializationList.Add(newJob);
        }
Exemple #7
0
        public void updatinSpecialization(Specialization newSpecialization)
        {
            Specialization LocalSpecialization = CopySpecialization(newSpecialization);
            int            index = DataSource.Specializations.FindIndex(s => s.ID == newSpecialization.ID);

            if (index == -1)
            {
                throw new Exception("Specialization with the same id not found...");
            }
            DataSource.Specializations[index] = newSpecialization;
            DataSource.SaveData(CollectionNames.Specializations);
        }
Exemple #8
0
        /// <summary>
        /// update specialization, verify if it is exists, if not throw exception
        /// </summary>
        /// <param name="newSpec"></param>
        public void UpdateSpecialization(Specialization newSpec)
        {
            Specialization spec = DS.DataSource.allSpecializations.FirstOrDefault(s => s.specializationNumber == newSpec.specializationNumber);

            if (spec == null)
            {
                throw new Exception("No specialization with the given details exists");
            }

            DS.DataSource.allSpecializations.Remove(spec);
            DS.DataSource.allSpecializations.Add(newSpec);
        }
Exemple #9
0
 public static List <User> GetList(Specialization specialization)
 {
     try
     {
         var userSpec = UsersSpecializationsRepository.GetList().Where(x => x.Specialization_Id == specialization.Id);
         return(GetList().Where(x => userSpec.Where(y => x.Id == y.User_Id).Any()).ToList());
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemple #10
0
        public void addSpecialization(Specialization newSpecialization)
        {
            Specialization LocalSpecialization = CopySpecialization(newSpecialization);

            ExceptionsOfSpecialization(LocalSpecialization);
            CollectionNames collectionName = CollectionNames.Specializations;
            var             list           = DataSource.Specializations;

            //Inventor number that does not exist in
            LocalSpecialization.ID = getID(collectionName);
            list.Add(LocalSpecialization);
            DataSource.SaveData(collectionName);
        }
Exemple #11
0
        public void UpdateSpecialization(Specialization newSpecialization)
        {
            var temp = GetSpecialization(newSpecialization.specializationNumber);

            if (temp == null)
            {
                throw new Exception("No specialization with the given details exists");
            }

            DelSpecialization(temp);
            AddSpecialization(newSpecialization);
            specializationsRoot.Save(specializationsPath);
        }
Exemple #12
0
        private Specialization CopySpecialization(Specialization newSpecialization)
        {
            Specialization LocalSpecialization = new Specialization
            {
                Name          = newSpecialization.Name,
                ID            = newSpecialization.ID,
                Regien        = newSpecialization.Regien,
                MaxHourSalary = newSpecialization.MaxHourSalary,
                MinHourSalary = newSpecialization.MinHourSalary
            };

            return(LocalSpecialization);
        }
Exemple #13
0
        public bool updateSpecilization(Specialization spec)
        {
            XElement foundElement = ElementIfExists(XML_Source.specializationRoot, spec.ID);

            if (foundElement == null)
            {
                throw new Exception(spec.ID + " does not exist in XML");
            }

            return
                (removeElementFromXML(XML_Source.specializationRoot, foundElement) &&
                 addSpecilization(spec));
        }
Exemple #14
0
        public bool addSpecilization(Specialization spec)
        {
            if (ElementIfExists(XML_Source.specializationRoot, spec.ID) != null)
            {
                throw new Exception(spec.ID + " already exists in file");
            }

            XML_Source.specializationRoot.Add(createSpecXElement(spec));
            XML_Source.SaveXML <Specialization>();

            nextSpecID++;
            return(true);
        }
Exemple #15
0
        public void updatinSpecialization(Specialization newSp)
        {
            Specialization value = DataSource.specialization.Find(x => x.ID == newSp.ID);

            if (value != null)
            {
                DataSource.specialization.Remove(value);
                DataSource.specialization.Add(newSp);
            }
            else
            {
                throw new NotImplementedException();
            }
        }
Exemple #16
0
        public void addSpecialization(Specialization specialization)
        {
            XElement root = XMLSource.SpecializationsElement;
            XElement specializationElement = new XElement(getXName("specialization"));

            specializationElement.SetAttributeValue(getXName("ID"), specialization.Id);
            specializationElement.Add(getXElement("name", specialization.Name));
            specializationElement.Add(getXElement("maxWageForHour", specialization.MaxWageForHour.ToString()));
            specializationElement.Add(getXElement("minWageForHour", specialization.MinWageForHour.ToString()));
            specializationElement.Add(getXElement("degree", specialization.Degree.ToString()));
            specializationElement.Add(getXElement("area", specialization.Area.ToString()));
            root.Add(specializationElement);
            root.Save(filePath(XMLSource.SpecializationsFile));
            XMLSource.SpecializationsElement = root;
        }
Exemple #17
0
        public void UpdateSpecialization(Specialization s)
        {
            int index = DS.DataSource.specialList.FindIndex(p => p.SpecialNum == s.SpecialNum);

            if (index == -1)
            {
                throw new Exception("Specialization with the same number not found");
            }
            #region update details
            DS.DataSource.specialList[index].Field      = s.Field;
            DS.DataSource.specialList[index].Field      = s.Field;
            DS.DataSource.specialList[index].SpecialNum = s.SpecialNum;
            DS.DataSource.specialList[index].TariffMax  = s.TariffMax;
            DS.DataSource.specialList[index].TariffMin  = s.TariffMin;
            #endregion
        }
        public void updateSpecialization(Specialization s)
        {
            XElement current = (from x in spacializations.Elements()
                                where x.Element("Number").Value == Convert.ToString(s.number)
                                select x).FirstOrDefault();

            if (current == null)
            {
                throw new Exception("the current specialization doesn't exist");
            }
            current.Element("SpecialtyName").Value = (s.name);
            current.Element("Speciality").Value    = Convert.ToString(s.speciality);
            current.Element("MinCost").Value       = Convert.ToString(s.minCost);
            current.Element("MaxCost").Value       = Convert.ToString(s.maxCost);
            spacializations.Save(SpecializationXml);
        }
Exemple #19
0
        public List <Specialization> getAllSpecializations()
        {
            List <Specialization> specs = new List <Specialization>();
            XElement root = XMLSource.SpecializationsElement;

            foreach (XElement specializationElement in root.Elements())
            {
                Specialization spec = new Specialization();
                spec.Id             = specializationElement.Attribute(getXName("ID")).Value;
                spec.Name           = getValue(specializationElement, "name");
                spec.MaxWageForHour = double.Parse(getValue(specializationElement, "maxWageForHour"));
                spec.MinWageForHour = double.Parse(getValue(specializationElement, "minWageForHour"));
                spec.Degree         = (Specialization.Education)Enum.Parse(typeof(Specialization.Education), getValue(specializationElement, "degree"));
                spec.Area           = (Proffesion)Enum.Parse(typeof(Proffesion), getValue(specializationElement, "area"));
                specs.Add(spec);
            }
            return(specs);
        }
Exemple #20
0
        public void updateExpert(Specialization e)
        {
            if (DS.DataSource.specializationList.Exists(c => c.specializationNumber == e.specializationNumber))
            {
                int index = DS.DataSource.specializationList.FindIndex(x => x.specializationNumber == e.specializationNumber);
                if (index != -1)
                {
                    DataSource.specializationList[index] = e;
                }
                else
                {
                    throw new KeyNotFoundException("The SpecializationId doesn't exist");
                }
            }

            else
            {
                throw new KeyNotFoundException("The SpecializationId doesn't exist");
            }
        }
        /// <summary>
        /// The purpose of this method is to get all specializations data based on filterExpression, sortExpression, pageIndex and pageSize parameters
        /// </summary>
        /// <param name="filterExpression">Where condition to be passed in SQL statement. DO NOT include WHERE keyword.</param>
        /// <param name="sortExpression">Sort column name with direction. For Example, "ProductID ASC")</param>
        /// <param name="pageIndex">Page number to be retrieved. Default is 0.</param>
        /// <param name="pageSize">Number of rows to be retrived. Default is 10.</param>
        /// <param name="rowsCount">Output: Total number of rows exist for the specified criteria.</param>
        /// <returns>List of specializationsData object</returns>
        public static List <Specialization> GetList(string filterExpression, string sortExpression, int pageIndex, int pageSize, out int rowsCount)
        {
            try
            {
                using (MySqlConnection cn = new MySqlConnection(connectionString))
                {
                    filterExpression = (string.IsNullOrEmpty(filterExpression) ? string.Empty : "WHERE " + filterExpression.Trim());
                    int    lbound = ((pageIndex - 1) * pageSize);
                    string strSQL = string.Format(SP_GET_BYPAGE, sortExpression, filterExpression, lbound, pageSize);
                    using (MySqlCommand cmd = new MySqlCommand(strSQL, cn))
                    {
                        cmd.CommandType = CommandType.Text;
                        cn.Open();
                        IDataReader reader = cmd.ExecuteReader(CommandBehavior.Default);

                        List <Specialization> objList = new List <Specialization>();
                        while (reader.Read())
                        {
                            //objList.Add(new specializationsData(
                            //         (int) reader["Id"], (string) reader["Name"], (int) reader["Faculty_Id"]));
                            objList.Add(Specialization.Parse(reader)); // Use this to avoid null issues
                        }
                        reader.NextResult();
                        reader.Read();
                        rowsCount = Convert.ToInt32(reader[0]);
                        reader.Close();

                        return(objList);
                    }
                }
            }
            catch (Exception ex)
            {
                // Put your code for Execption Handling here
                // 1. Log the error
                // 2. Handle or Throw Exception
                // This is my code...Customized!!!!
                // Note: You may modify code generation template by editing ExceptionHandler CodeBlock
                throw ex;
            }
        }
Exemple #22
0
        public void DelSpecialization(Specialization oldSpecialization)
        {
            if (GetSpecialization(oldSpecialization.specializationNumber) == null)
            {
                throw new Exception("No specialization with the given details exists");
            }

            try
            {
                var element = (from s in specializationsRoot.Elements()
                               where Convert.ToInt32(s.Attribute("Specialization_number").Value) == oldSpecialization.specializationNumber
                               select s).FirstOrDefault();

                element.Remove();
                specializationsRoot.Save(specializationsPath);
            }
            catch
            {
                throw new Exception("Error deleting from file: " + specializationsRoot);
            }
        }
        public void RemoveSpecialization(int num)
        {
            Specialization sp = GetSpecialization(num);

            if (sp == null)
            {
                throw new Exception("Specialization with the same num not found");
            }

            XElement specializationElement;

            try
            {
                specializationElement = (from p in specializationRoot.Elements()
                                         where Convert.ToInt32(p.Element("SpecialNum").Value) == num
                                         select p).FirstOrDefault();
                specializationElement.Remove();
                specializationRoot.Save(specializationPath);
            }
            catch
            {
            }
        }
Exemple #24
0
 public void updateExpert(Specialization s)
 {
     if (s.specializationNumber == 0)
     {
         throw new Exception("the specialization do not contain id");
     }
     else if (s.minTarif == 0)
     {
         throw new Exception("the specilization does not have a minTarif");
     }
     else if (s.maxTarif == 0)
     {
         throw new Exception("the specialization does not have a maxTarif");
     }
     else if (SpecializationExist(s.specializationNumber))
     {
         eraseExpert(s.specializationNumber);
         this.addExpert(s);
     }
     else
     {
         throw new Exception("the specialization number to update: " + s.specializationNumber + " not exist");
     }
 }
        public void AddSpecialization(Specialization specialization)
        {
            int num = int.Parse(staticNumberRoot.Element("staticNumber").Element("specialization").Value);

            num++;
            staticNumberRoot.Element("staticNumber").Element("specialization").Value = Convert.ToString(num);
            Specialization sp = GetSpecialization(num);

            if (sp != null)
            {
                throw new Exception("Specialization with the same number already exists");
            }
            staticNumberRoot.Save(staticNumberPath);
            specialization.SpecialNum = num;
            XElement Specialnum         = new XElement("SpecialNum", num);
            XElement SpecializationName = new XElement("SpecializationName", specialization.SpecializationName);
            XElement Field     = new XElement("Field", specialization.Field);
            XElement TariffMin = new XElement("TariffMin", specialization.TariffMin);
            XElement TariffMax = new XElement("TariffMax", specialization.TariffMax);
            XElement Tarif     = new XElement("Tarif", TariffMin, TariffMax);

            specializationRoot.Add(new XElement("specialization", Specialnum, SpecializationName, Field, Tarif));
            specializationRoot.Save(specializationPath);
        }
Exemple #26
0
 public object GetobjectById(object obj)
 {
     if (obj is Specialization)
     {
         Specialization specialization = (Specialization)obj;
         return((object)(DataSource.Specializations.FirstOrDefault(s => s.ID == specialization.ID)));
     }
     else if (obj is Contract)
     {
         Contract contract = (Contract)obj;
         return((object)(DataSource.Contracts.FirstOrDefault(s => s.ID == contract.ID)));
     }
     else if (obj is Employee)
     {
         Employee employee = (Employee)obj;
         return((object)(DataSource.Employees.FirstOrDefault(s => s.ID == employee.ID)));
     }
     if (obj is Employer)
     {
         Employer employer = (Employer)obj;
         return((object)(DataSource.Employers.FirstOrDefault(s => s.ID == employer.ID)));
     }
     return(null);
 }
Exemple #27
0
 public void addExpert(Specialization s)
 {
     if (s.specializationNumber == 0)
     {
         throw new Exception("the specialization does not contain ID");
     }
     else if (s.minTarif == 0)
     {
         throw new Exception("the specialization does not containt min tarif");
     }
     else if (s.minTarif == 0)
     {
         throw new Exception("the specialization does not contain a max tarif");
     }
     else if (SpecializationExist(s.specializationNumber))
     {
         throw new Exception("the specialization id to add: " + s.specializationNumber + "  not exist");
     }
     else
     {
         specialization_ROOT.Add(ConvertSpecialization(s));
         SaveFiles();
     }
 }
Exemple #28
0
 /// <summary>
 /// Adds a specialization to the database
 /// </summary>
 /// <param name="specialization">The specialization to add</param>
 public void addSpecialization(Specialization specialization) =>
 addToList <Specialization>(ListSource.specList, specialization);
Exemple #29
0
 /// <summary>
 /// Updates a specizliation in the database
 /// </summary>
 /// <param name="newSpecialization">the new updated specialization</param>
 /// <param name="oldSpecialization">the old specialization to update</param>
 public void updateSpecialization(Specialization newSpecialization, Specialization oldSpecialization) =>
 UpdateItem <Specialization>(ListSource.specList, newSpecialization, oldSpecialization);
Exemple #30
0
 /// <summary>
 /// Removes a specialization from the database
 /// </summary>
 /// <param name="specialization">The specialization to remove</param>
 public void removeSpecialization(Specialization specialization) =>
 RemoveItem <Specialization>(ListSource.specList, specialization);