예제 #1
0
        /// <summary>
        /// Update detail entity data,
        /// Todo: For insert, need meet business rules and supply valid fields
        /// </summary>
        /// <param name="model"></param>
        private void UpdateDetailFields(T model)
        {
            if (model.CustomerOptionalFields != null)
            {
                foreach (var item in model.CustomerOptionalFields)
                {
                    var filter = "(IDCUST = \"" + item.CustomerNumber + "\") AND (OPTFIELD = \"" + item.OptionalField + "\")";
                    _detail.Browse(filter, true);

                    if (_detail.Fetch(false))
                    {
                        _detailMapper.Map(item, _detail);
                        if (model.HasChanged)
                        {
                            _detail.Update();
                        }
                        else if (model.IsDeleted)
                        {
                            _detail.Delete();
                        }
                    }
                    else
                    {
                        if (model.IsNewLine)
                        {
                            _detailMapper.Map(item, _detail);
                            _detail.Insert();
                        }
                    }
                }
            }
        }
예제 #2
0
 public virtual void Delete(T entity)
 {
     if (entity == null)
     {
         throw new ArgumentNullException(nameof(entity));
     }
     _bizLayer.Delete(entity);
 }
        /// <summary>
        /// Delete
        /// </summary>
        /// <param name="id">Source Journal Name</param>
        /// <returns>SourceJournalProfile</returns>
        public T Delete(string id)
        {
            _businessEntity = CreateBusinessEntities();
            _businessEntity.SetValue(SourceJournalProfile.Fields.SourceJournalName, id);

            if (_businessEntity.Read(false))
            {
                _businessEntity.Delete();
            }
            else
            {
                throw ExceptionHelper.RowNotFoundException(CommonResx.DeleteFailedNoRecordMessage);
            }

            _businessEntity.Cancel();

            var mapper = new SourceJournalProfileMapper <T>(_context);

            return(mapper.Map(_businessEntity));
        }