Ejemplo n.º 1
0
        public Task <TaskResult> SaveJournalContent(JournalContent content, ModifyType modify)
        {
            Task <TaskResult> res = null;

            if (modify == ModifyType.Update)
            {
                res = ServiceRunTask(service =>
                {
                    service.UpdateJournalContent(content);
                    return(null);
                });
            }
            else if (modify == ModifyType.Insert)
            {
                res = ServiceRunTask(service =>
                {
                    content.exam_date_id = CurrentJournal.exam_date_id;
                    return(service.InsertJournalContent(content));
                });
            }
            else if (modify == ModifyType.Delete)
            {
                res = ServiceRunTask(service =>
                {
                    return(service.DeleteJournalContent(content.id));
                });
            }
            return(res);
        }
Ejemplo n.º 2
0
        private async void RefreshJournal(RadGridView grid, int id = -1)
        {
            IsBusy = true;
            try
            {
                JournalContent grid_item = (JournalContent)grid.SelectedItem;
                string         col_name  = grid.CurrentCellInfo != null ? grid.CurrentCellInfo.Column.UniqueName : "";

                TaskResult res = await service.UpdateCurrentJournalContent(service.CurrentJournal.exam_date_id);

                if (res.fault != null)
                {
                    service.CurrentJournalContent = null;
                    AddError("error", res.fault.Message);
                }
                else
                {
                    UpdateJournal();
                    JournalContent prev_item = null;
                    if (id > 0)
                    {
                        prev_item = service.CurrentJournalContent.Where(x => x.id == id).SingleOrDefault();
                    }
                    else if (grid_item != null && col_name != "")
                    {
                        prev_item = service.CurrentJournalContent.Where(x => x.id == grid_item.id).SingleOrDefault();
                    }
                    else
                    {
                        prev_item = (JournalContent)grid.CurrentItem;
                    }
                    grid.CurrentCellInfo = new GridViewCellInfo(prev_item, grid.Columns[col_name]);
                    grid.Focus();
                    if (prev_item != null)
                    {
                        grid.SelectedItem = prev_item;
                        grid.ScrollIntoView(prev_item);
                    }
                }
                IsBusy = false;
            }
            catch (System.Exception e)
            {
                IsBusy = false;
                AddError("error", e.Message);
            }
        }