示例#1
0
        private void Add()
        {
            var d = new Faculty();

            Faculties.Add(d);
            SelectedFaculty = d;
            RaisePropertyChanged("Faculties");
        }
示例#2
0
        public void Seed()
        {
            if (!Faculties.Any())
            {
                Faculties.Add(new Faculty {
                    Name = "FNWI"
                });
                SaveChanges();
            }

            if (!SecurityQuestions.Any())
            {
                List <SecurityQuestions> questions = new List <SecurityQuestions>();
                void AddQuestion(string text, DeviceType mask)
                {
                    questions.Add(new Data.SecurityQuestions()
                    {
                        Text = text,
                        Mask = mask,
                    });
                }

                AddQuestion("Does the device have encrypted storage?", DeviceType.All);
                AddQuestion("Are local accounts only accessible with strong passwords?", DeviceType.All);
                AddQuestion("Does the device have a strong access code(minimum 6 characters) other than the SIM card PIN code?", DeviceType.Mobile | DeviceType.Tablet);
                AddQuestion("The OS and all applications are maintained by a supplier or community, and are up to date including security updates.", DeviceType.All);
                AddQuestion("Applicable anti malware and antivirus solutions are present, active and up to date.", DeviceType.All);
                AddQuestion("Local (application) firewall is active and alerts the user to unusual behaviour.", DeviceType.Desktop | DeviceType.Laptop);
                AddQuestion("Laptop or desktop should be automatically locked after a pre-set period of inactivity after a maximum of 15 minutes and phones or tablets after 5 minutes.", DeviceType.Desktop | DeviceType.Laptop);
                AddQuestion("Remote wipe, lock, or effective data protection measures to prevent loss of setting information in the event of theft should be in place.", DeviceType.All);
                SecurityQuestions.AddRange(questions);
                SaveChanges();
            }

            int facultyId = Faculties.First(f => f.Name == "FNWI").Id;
            var userIds   = new string[] { User.ImporterId, User.IntuneServiceId, User.LabnetId, User.ExpireId };

            foreach (string id in userIds)
            {
                if (!Users.Any(u => u.UserName == id))
                {
                    Users.Add(new User()
                    {
                        Name      = id,
                        UserName  = id,
                        FacultyId = facultyId,
                        Email     = "*****@*****.**",
                    });
                    SaveChanges();
                }
            }
        }
        private async void OnAddFaculty()
        {
            SelectedFaculty.FacultyId = 0;

            var facultyNames = (await _repo.GetFacultiesAsync()).Select(f => f.Name).ToList();

            if (facultyNames.Contains(SelectedFaculty.Name))
            {
                MessageBox.Show("Факульте с таким именем уже существует.", "Ошибка");
                return;
            }

            var result = await _repo.AddFacultyAsync(SelectedFaculty);

            Faculties.Add(result);
        }
示例#4
0
        private void RefreshFacultyProperty()
        {
            Faculties.Clear();

            try
            {
                Faculty item0 = new Faculty {
                    Id = 0, Name = string.Empty
                };
                Faculties.Add(item0);
                DbContext.Faculties.OrderBy(x => x.Name).ToList().ForEach(x => Faculties.Add(x));
                OnPropertyChanged(nameof(Faculties));
            }
            catch (EntityException e)
            {
                OnEntityException(e);
            }
            catch (DbEntityValidationException e)
            {
                OnDbEntityValidationException(e);
            }
        }
示例#5
0
        // A realtime database transaction receives MutableData which can be modified
        // and returns a TransactionResult which is either TransactionResult.Success(data) with
        // modified data or TransactionResult.Abort() which stops the transaction with no changes.
        TransactionResult AddScoreTransaction(MutableData mutableData)
        {
            List <object> Faculties = mutableData.Value as List <object>;

            if (Faculties == null)
            {
                Faculties = new List <object>();
            }
            else if (mutableData.ChildrenCount >= MaxScores)
            {
                // If the current list of scores is greater or equal to our maximum allowed number,
                // we see if the new score should be added and remove the lowest existing score.
                long   minScore = long.MaxValue;
                object minVal   = null;
                foreach (var child in Faculties)
                {
                    if (!(child is Dictionary <string, object>))
                    {
                        continue;
                    }
                    long   childScore = (long)((Dictionary <string, object>)child)["score"];
                    string extension  = (string)((Dictionary <string, object>)child)["extension"];

                    Debug.Log("extension url get working **************************************** " + extension);
                    if (childScore < minScore)
                    {
                        minScore = childScore;
                        minVal   = child;
                    }
                }
                // If the new score is lower than the current minimum, we abort.
                if (minScore > score)
                {
                    return(TransactionResult.Abort());
                }
                // Otherwise, we remove the current lowest to be replaced with the new score.
                Faculties.Remove(minVal);
            }

            // Now we add the new score as a new entry that contains the email address and score.
            Dictionary <string, object> newScoreMap = new Dictionary <string, object>();

            //newScoreMap["score"] = score;
            //newScoreMap["email"] = email;
            //***********************************************************************************************************************************************
            newScoreMap["year"]        = Global.year;
            newScoreMap["facultyname"] = Global.faculty_name;
            newScoreMap["subject"]     = Global.subject;

            newScoreMap["section"] = Global.section;

            newScoreMap["category_name"] = Global.category_name;

            newScoreMap["filename"]  = Global.destination_filename_with_extension_for_uploading;
            newScoreMap["extension"] = Global.extension;

            //newScoreMap["filename_url"] = Global.faculty_name + "/" + Global.year + "/" + Global.subject + "/" + Global.section + "/" + Global.category_name + "/" + Global.destination_filename_with_extension_for_uploading;

            //***********************************************************************************************************************************************
            Faculties.Add(newScoreMap);
            //Faculties.Add("Faculties/" + Global.faculty_name + "/" + Global.year + "/" + Global.subject + "/" + Global.section + "/" + Global.category_name + "/" + Global.destination_filename_with_extension_for_uploading );

            // You must set the Value to indicate data at that location has changed.
            mutableData.Value = Faculties;
            return(TransactionResult.Success(mutableData));
        }
示例#6
0
 public void AddFaculty(Faculty facultyToAdd)
 {
     Faculties.Add(facultyToAdd);
 }
示例#7
0
 public void SetFaculty(int id, Faculty faculty)
 {
     Faculties.Add(id, faculty);
 }
示例#8
0
        public static void Init()
        {
            Specialties.Add(new Speciality
            {
                FacultyId = 123,
                Id        = 2,
                LectorId  = 321,
                Name      = "Telecommunications",
                ShortName = "TIS"
            });
            Users.Add(new User
            {
                Id         = 1,
                FacultylID = 123,
                Name       = "Boris",
                Email      = "*****@*****.**",
                TeamID     = 12
            });

            Users.Add(new User
            {
                Id         = 2,
                FacultylID = 456,
                Name       = "Stefan",
                Email      = "*****@*****.**",
                TeamID     = 12
            });

            //Initi Story
            Stories.Add(new Story
            {
                Id          = 55,
                Name        = "Controlers Story",
                Description = "Create all required controlers",
                EndDate     = new DateTime(2020, 12, 23),
                ProjectId   = 2,
                StartDate   = DateTime.Now
            });

            //Inti faculties

            Faculties.Add(new Faculty()
            {
                Id          = 1,
                Name        = "Physico-technological faculty",
                Description = "We are the best",
                ShortName   = "PTF"
            });

            //Init Teams
            Teams.Add(new Team
            {
                Id          = 43,
                Name        = "Team A",
                FacultyID   = 1,
                DateCreated = new DateTime(2019, 10, 01)
            });

            Teams.Add(new Team
            {
                Id          = 44,
                Name        = "Team B",
                FacultyID   = 1,
                DateCreated = new DateTime(2019, 10, 01)
            });

            //Init User Taks
            UserTasks.Add(new UserTask
            {
                Id = 23,
                AssignedToUserID = 2,
                Description      = "Task Description",
                EndDate          = new DateTime(2020, 11, 23),
                Name             = "Create Controlers",
                OwnerId          = 1,
                StartDate        = DateTime.Now,
                StoryId          = 55
            });

            Sprints.Add(new Sprint
            {
                Description = "Description",
                EndDate     = DateTime.Now.AddDays(5),
                Id          = 133,
                Name        = "Sprint name",
                StartDate   = DateTime.Now,
                TeamID      = 1
            });
            Lectors.Add(new Lector
            {
                Id          = 24,
                FirstName   = "Vladimir",
                LastName    = "Sovniov",
                DateStarted = new DateTime(2018, 10, 12)
            });

            Projects.Add(new Project
            {
                Description = "Project description",
                Id          = 4322,
                Name        = "Some project name",
                OwnerId     = 2
            });

            //User positions
            UserPositions.Add(new UserPosition
            {
                Id           = 1,
                PositionName = "Junior Developer",
                Description  = "Begginer C# developer"
            });
            UserPositions.Add(new UserPosition
            {
                Id           = 2,
                PositionName = "Middle Developer",
                Description  = "Experienced C# developer"
            });
            UserPositions.Add(new UserPosition
            {
                Id           = 3,
                PositionName = "Senior Developer",
                Description  = "Very experienced C# developer"
            });
        }
示例#9
0
 public void AddFaculty(Faculty faculty)
 {
     Faculties.Add(faculty);
 }
示例#10
0
        static SeedGetter()
        {
            var fileName   = "dataseed.json";
            var path       = Path.Combine(Environment.CurrentDirectory, fileName);
            var jsonString = File.ReadAllTextAsync(path).Result;
            var seed       = JsonConvert.DeserializeObject <DataSeed>(jsonString);

            foreach (var user in seed.DeanEmployees)
            {
                var preparedUser = PrepareUser(user);
                Users.Add(preparedUser);
                DeanEmployees.Add(preparedUser);
            }
            foreach (var student in seed.Students)
            {
                var user = PrepareUser(student.ApplicationUser);
                Users.Add(user);
                student.ApplicationUser = null;
                student.UserId          = user.Id;

                //if (student.Id == Guid.Empty)
                //{
                //    student.Id = Guid.NewGuid();
                //}
                Students.Add(student);
            }
            foreach (var institute in seed.Institutes)
            {
                //if (institute.Id == Guid.Empty)
                //{
                //    institute.Id = Guid.NewGuid();
                //}

                foreach (var promoter in institute.Promoters)
                {
                    var user = PrepareUser(promoter.ApplicationUser);
                    Users.Add(user);
                    promoter.ApplicationUser = null;
                    promoter.UserId          = user.Id;
                    promoter.InstituteId     = institute.Id;
                    //if (promoter.Id == Guid.Empty)
                    //{
                    //    promoter.Id = Guid.NewGuid();
                    //}
                    Promoters.Add(promoter);
                }
                institute.Promoters = null;
                Institutes.Add(institute);
            }
            foreach (var faculty in seed.Faculties)
            {
                //if (faculty.Id == Guid.Empty)
                //{
                //    faculty.Id = Guid.NewGuid();
                //}

                foreach (var course in faculty.Courses)
                {
                    //if (course.Id == Guid.Empty)
                    //{
                    //    course.Id = Guid.NewGuid();
                    //}
                    course.FacultyId = faculty.Id;
                    foreach (var proposal in course.Proposals)
                    {
                        //if (proposal.Id == Guid.Empty)
                        //{
                        //    proposal.Id = Guid.NewGuid();
                        //}
                        proposal.CourseId     = course.Id;
                        proposal.StartingDate = new DateTime(2019, 10, 1);
                        Proposals.Add(proposal);
                    }
                    course.Proposals = null;
                    Courses.Add(course);
                }
                faculty.Courses = null;
                Faculties.Add(faculty);
            }
        }