private async void OnRemoveFaculty()
        {
            var facultySpecialities = await _sRepo.GetFilteredSpecialtiesAsync(s =>
                                                                               s.FacultyId == SelectedFaculty.FacultyId);

            if (facultySpecialities.Count > 0)
            {
                var result = MessageBox.Show(
                    "Вы точно хотите удалить факультет вместе с прикреплёнными специальностями и студентами?",
                    "К этому факультету прикреплены специальности.",
                    MessageBoxButton.YesNo);

                switch (result)
                {
                case MessageBoxResult.Yes:
                    break;

                case MessageBoxResult.No:
                    return;

                default:
                    return;
                }
            }

            await _repo.DeleteFacultyWithSpecialitiesAndStudentsAsync(SelectedFaculty.FacultyId);

            var faculty = Faculties.FirstOrDefault(f => f.FacultyId == SelectedFaculty.FacultyId);

            if (faculty != null)
            {
                Faculties.Remove(faculty);
            }
        }
示例#2
0
 public void RemoveFaculty(Faculty facultyToRemove)
 {
     if (Faculties.Contains(facultyToRemove))
     {
         Faculties.Remove(facultyToRemove);
     }
 }
        private void RemoveRow_ButtonClick(object sender, RoutedEventArgs e)
        {
            try
            {
                if (CurrentRow != null)
                {
                    var messageBoxResult = MessageBox.Show("Вы действительно удалить данный факультет?", "Подтверждение действия",
                                                           MessageBoxButton.YesNo, MessageBoxImage.Question);

                    if (messageBoxResult == MessageBoxResult.Yes)
                    {
                        Connection.Database.faculties.Remove(CurrentRow);
                        Faculties.Remove(CurrentRow);

                        Connection.Database.SaveChanges();
                    }
                }
                else
                {
                    MessageBox.Show("Аудитория не выбрана.", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Warning);
                }
            }
            catch (Exception err)
            {
                MessageBox.Show(err.Message, "Ошибка сохранения", MessageBoxButton.OK, MessageBoxImage.Warning);
                Connection.Database.faculties.Remove(CurrentRow);
            }
        }
示例#4
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));
        }