Exemple #1
0
        public IActionResult SaveRecordData(RecordVM data)
        {
            CommonResponse <int> commonResponse = new CommonResponse <int>();

            //returns response in JS Notify
            try
            {
                commonResponse.status = _recordService.AddUpdate(data).Result;
                if (commonResponse.status == 1)
                {
                    commonResponse.message = Helper.recordUpdated;
                }
                if (commonResponse.status == 2)
                {
                    commonResponse.message = Helper.recordAdded;
                }
            }
            catch (Exception e)
            {
                commonResponse.message = e.Message;
                commonResponse.status  = Helper.failure_code;
            }

            return(Ok(commonResponse));
        }
Exemple #2
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                var dd = RecordVM.RecordSelected.Timesensitive == null
                    ? ""
                    : RecordVM.RecordSelected.Timesensitive.Value.ToString("yyyy-MM-dd");


                ForceValidation();
                bool          isValid       = true;
                List <string> validationMsg = new List <string>();


                if (string.IsNullOrWhiteSpace(RecordVM.RecordSelected.Process))
                {
                    validationMsg.Add("Vorgang darf nicht leer sein.");
                    isValid = false;
                }
                if (string.IsNullOrWhiteSpace(RecordVM.RecordSelected.CostType))
                {
                    validationMsg.Add("Kostenart darf nicht leer sein.");
                    isValid = false;
                }

                if (!isValid)
                {
                    new NotificationWindow("Fehler!", null, validationMsg, NotificationWindow.MessageType.Error).Show();
                    return;
                }

                var result = RecordVM.Add();
                if (result.Records > 0)
                {
                    Record record = RecordUpdated(result.Id);
                    RecordVM.RecordSelected = record;



                    var titel = string.Format("Vorgang : {0}", record.GetFullName());
                    var msg   = "Vorgangsdaten wurden gespeichert.";
                    new NotificationWindow(titel, msg, null, NotificationWindow.MessageType.Error).Show();

                    EnableContoles(false);
                }
                else
                {
                    var msg = "Vorgangsdaten konnten nicht gespeichert werden.";
                    new NotificationWindow("Fehler!", msg).Show();
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
                var msg = "Vorgangsdaten konnten nicht gespeichert werden.";
                new NotificationWindow("Fehler!", exception.ToString(), null, NotificationWindow.MessageType.Error).Show();
            }
        }
Exemple #3
0
        private void btnCancel_Click(object sender, RoutedEventArgs e)
        {
            if (RecordVM.RecordSelected.ReadOnly)
            {
                RecordVM.ReleaseEditing();
            }

            RecordVM.RecordSelected = RecordVM.RecordSelectedLast;
            EnableContoles(false);
        }
Exemple #4
0
        private void addRow(RecordVM record)
        {
            var texts = new[]
            {
                record.Date.ToShortDateString(),
                record.MinutesTotal.ToString(),
                record.DistanceTotal.ToString(),
                record.AverageSpeed.ToString("0.##"),
                record.Note,
            };
            var viewItem = new ListViewItem(texts);

            cyclingDiaryLv.Items.Add(viewItem);
        }
Exemple #5
0
        public async Task <int> AddUpdate(RecordVM model)
        {
            var startDate  = DateTime.Parse(model.ActualStartDateTime);
            var endDate    = DateTime.Parse(model.EndDateTime);
            var targetDate = DateTime.Parse(model.TargetDateTime);

            if (model != null && model.Id > 0)
            {
                //update
                var record = _db.Records.FirstOrDefault(x => x.Id == model.Id);
                record.RecordTitle         = model.RecordTitle;
                record.PatientName         = model.PatientName;
                record.UserName            = model.UserName;
                record.ActualStartDateTime = startDate;
                record.TargetDateTime      = targetDate;
                record.Reason      = model.Reason;
                record.Action      = model.Action;
                record.Completed   = model.Completed;
                record.EndDateTime = endDate;
                record.Outcome     = model.Outcome;
                await _db.SaveChangesAsync();

                return(1);
            }
            else
            {
                //create
                Record record = new Record()
                {
                    RecordTitle         = model.RecordTitle,
                    PatientName         = model.PatientName,
                    UserName            = model.UserName,
                    ActualStartDateTime = startDate,
                    TargetDateTime      = targetDate,
                    Reason      = model.Reason,
                    Action      = model.Action,
                    Completed   = model.Completed,
                    EndDateTime = endDate,
                    Outcome     = model.Outcome
                };

                _db.Records.Add(record);
                await _db.SaveChangesAsync();

                return(2);
            }
        }
Exemple #6
0
        private static List <RecordVM> GetActiveRecords(RecordVM rootRecord, Guid currentId)
        {
            if (rootRecord == null)
            {
                throw new ArgumentNullException(nameof(rootRecord));
            }
            IEnumerable <RecordVM> activeList = new List <RecordVM>();

            var active = rootRecord.Find(currentId);

            while (active != null)
            {
                activeList = activeList.Prepend(active);
                active     = rootRecord.Find(r => r.Children != null && r.Children.Contains(active));
            }
            return(activeList.ToList());
        }
Exemple #7
0
        private void btnEdit_Click(object sender, RoutedEventArgs e)
        {
            RecordVM.RecordSelectedLast = RecordVM.RecordSelected;
            var result = RecordVM.EditRecord();

            if (result.IsReadOnly)
            {
                AskForceToEdit(result.CurrentlyUsedBy, () =>
                {
                    RecordVM.ForceEditing();
                    EnableContoles(true);
                });
            }
            else
            {
                EnableContoles(true);
            }
        }
        public List <RecordVM> GetAll()
        {
            var items  = readFromFileOrdered();
            var result = new List <RecordVM>();

            foreach (var item in items)
            {
                var record = new RecordVM
                {
                    ID            = item.ID,
                    Date          = item.Date,
                    MinutesTotal  = item.MinutesTotal,
                    DistanceTotal = item.DistanceTotal,
                    AverageSpeed  = item.MinutesTotal > 0
                                                ? (item.DistanceTotal / item.MinutesTotal * 60)
                                                : 0,
                    Note = item.Note,
                };
                result.Add(record);
            }
            return(result);
        }
Exemple #9
0
        private CourseFullInfoVM GetExample(Guid id)
        {
            var root = new RecordVM
            {
                Id    = new Guid(new byte[] { 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }),
                Type  = RecordType.Root,
                Title = "ROOT"
            };
            var chapter1 = new RecordVM
            {
                Id    = new Guid(new byte[] { 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }),
                Type  = RecordType.Group,
                Title = "Введение в C#"
            };
            var article1_1 = new RecordVM
            {
                Type  = RecordType.Article,
                Id    = new Guid(new byte[] { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }),
                Title = "Язык C# и платформа .NET"
            };
            var article1_2 = new RecordVM
            {
                Type  = RecordType.Article,
                Id    = new Guid(new byte[] { 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }),
                Title = "Начало работы с Visual Studio. Первая программа"
            };
            var article1_3 = new RecordVM
            {
                Type  = RecordType.Article,
                Id    = new Guid(new byte[] { 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }),
                Title = "Компиляция в командной строке"
            };
            var chapter2 = new RecordVM
            {
                Id    = new Guid(new byte[] { 1, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }),
                Type  = RecordType.Group,
                Title = "Основы программирования на C#"
            };
            var article2_1 = new RecordVM
            {
                Type  = RecordType.Article,
                Id    = new Guid(new byte[] { 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }),
                Title = "Структура программы"
            };
            var subchapter2_2 = new RecordVM
            {
                Type  = RecordType.Group,
                Id    = new Guid(new byte[] { 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }),
                Title = "Работа с данными"
            };
            var article2_2_1 = new RecordVM
            {
                Type  = RecordType.Article,
                Id    = new Guid(new byte[] { 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }),
                Title = "Переменные"
            };
            var article2_2_2 = new RecordVM
            {
                Type  = RecordType.Article,
                Id    = new Guid(new byte[] { 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }),
                Title = "Литералы"
            };
            var article2_2_3 = new RecordVM
            {
                Type  = RecordType.Article,
                Id    = new Guid(new byte[] { 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }),
                Title = "Типы данных"
            };
            var article2_3 = new RecordVM
            {
                Type  = RecordType.Article,
                Id    = new Guid(new byte[] { 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }),
                Title = "Консольный ввод-вывод"
            };
            var subchapter2_4 = new RecordVM
            {
                Type  = RecordType.Group,
                Id    = new Guid(new byte[] { 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }),
                Title = "Операции с данными"
            };
            var article2_4_1 = new RecordVM
            {
                Type  = RecordType.Article,
                Id    = new Guid(new byte[] { 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }),
                Title = "Арифметические операции"
            };
            var article2_4_2 = new RecordVM
            {
                Type  = RecordType.Article,
                Id    = new Guid(new byte[] { 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }),
                Title = "Поразрядные операции"
            };
            var article2_4_3 = new RecordVM
            {
                Type  = RecordType.Article,
                Id    = new Guid(new byte[] { 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }),
                Title = "Операции присваивания"
            };
            var article2_4_4 = new RecordVM
            {
                Type  = RecordType.Article,
                Id    = new Guid(new byte[] { 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }),
                Title = "Преобразование базовых типов данных"
            };

            root.Children          = new() { chapter1, chapter2 };
            chapter1.Children      = new() { article1_1, article1_2, article1_3 };
            chapter2.Children      = new() { article2_1, subchapter2_2, article2_3, subchapter2_4 };
            subchapter2_2.Children = new() { article2_2_1, article2_2_2, article2_2_3 };
            subchapter2_4.Children = new() { article2_4_1, article2_4_2, article2_4_3, article2_4_4 };

            var course = new CourseFullInfoVM()
            {
                Id          = id,
                Title       = "Основы C#",
                Description = "Курс рассчитан на людей с минимальным опытом программирования и знакомит с основами синтаксиса C#" +
                              " и стандартными классами .NET, с основами ООП и базовыми алгоритмами.",
                //ImgSrc = "https://avatars.mds.yandex.net/get-zen_doc/4423710/pub_608fda25a38d215d4e183cba_60928147de56f009bc84b924/scale_1200",
                Difficulty = Difficulty.Beginer,
                Rating     = new RatingModel
                {
                    Rating      = 4.5,
                    VotersCount = 108
                },
                RootRecord = root
            };

            return(course);
        }