示例#1
0
        public NoteRender Update(NoteRender entity)
        {
            Guard.Against <ArgumentNullException>(entity == null, nameof(entity));

            // ReSharper disable once PossibleNullReferenceException
            if (entity.Id <= 0)
            {
                ProcessMessage.Success = false;
                ProcessMessage.AddErrorMessage($"Can not update NoteRender with id {entity.Id}", true);
                return(null);
            }

            try
            {
                // make sure the record exists in data source
                DataContext.Renders.Update(entity);
                DataContext.Save();
                return(LookupRepo.GetEntity <NoteRender>(entity.Id));
            }
            catch (Exception ex)
            {
                ProcessMessage.WrapException(ex);
                return(null);
            }
        }
示例#2
0
        public Author Update(Author entity)
        {
            Guard.Against <ArgumentNullException>(entity == null, nameof(entity));

            try
            {
                // ReSharper disable once PossibleNullReferenceException
                if (entity.Id == Guid.Empty)
                {
                    ProcessMessage.Success = false;
                    ProcessMessage.AddErrorMessage($"Can not update author with id {entity.Id}");
                    return(null);
                }

                _dataContext.Authors.Update(entity);
                Flush();
                var updateAuthor = _lookupRepo.GetEntity <Author>(entity.Id);
                return(updateAuthor);
            }
            catch (DataSourceException ex)
            {
                ProcessMessage.WrapException(ex);
                return(null);
            }
        }
示例#3
0
        public NoteCatalog Update(NoteCatalog entity)
        {
            Guard.Against <ArgumentNullException>(entity == null, nameof(entity));

            // ReSharper disable once PossibleNullReferenceException
            if (entity.Id <= 0)
            {
                ProcessMessage.Success = false;
                ProcessMessage.AddErrorMessage($"Can not update NoteCatalog with id {entity.Id}", true);
                return(null);
            }

            try
            {
                // check if need apply default render
                var          render  = PropertyChecking(entity.Render);
                const string message = "Cannot find default note render.";
                ProcessMessage.Success = false;
                ProcessMessage.AddErrorMessage(message, true);
                entity.Render = render ?? throw new DataSourceException(message);

                DataContext.Catalogs.Update(entity);
                DataContext.Save();
                return(LookupRepo.GetEntity <NoteCatalog>(entity.Id));
            }
            catch (Exception ex)
            {
                ProcessMessage.WrapException(ex);
                return(null);
            }
        }
示例#4
0
        public async Task <Subsystem> UpdateAsync(Subsystem entity)
        {
            Guard.Against <ArgumentNullException>(entity == null, nameof(entity));

            // ReSharper disable once PossibleNullReferenceException
            if (entity.Id <= 0)
            {
                ProcessMessage.Success = false;
                ProcessMessage.AddErrorMessage($"Can not update Subsystem with id {entity.Id}", true);
                return(null);
            }

            try
            {
                // make sure the record exists in data source
                DataContext.Subsystems.Update(entity);
                await DataContext.SaveAsync();

                return(LookupRepo.GetEntity <Subsystem>(entity.Id));
            }
            catch (Exception ex)
            {
                ProcessMessage.WrapException(ex);
                return(null);
            }
        }