Beispiel #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public async Task <List <ProductCategory> > Delete(IDeleteProductCategory data)
        {
            List <ProductCategory> productCategories = new List <ProductCategory>();

            foreach (var id in data.Ids)
            {
                var filter = Builders <ProductCategory> .Filter.Eq("Id", id);

                filter &= Builders <ProductCategory> .Filter.Eq("CompanyId", data.CompanyId);

                var update = Builders <ProductCategory> .Update
                             .Set(s => s.IsDelete, true)
                             .Set(s => s.UpdatedBy, data.UpdatedBy)
                             .CurrentDate(s => s.UpdatedAt);

                var options = new FindOneAndUpdateOptions <ProductCategory>
                {
                    ReturnDocument = ReturnDocument.After
                };
                var productCategory = await _context.ProductCategory.FindOneAndUpdateAsync(filter, update, options);

                productCategories.Add(productCategory);
            }
            return(productCategories);
        }
        protected virtual IProductCategoryStateDeleted Map(IDeleteProductCategory c)
        {
            var stateEventId = new ProductCategoryEventId(c.ProductCategoryId, c.Version);
            IProductCategoryStateDeleted e = NewProductCategoryStateDeleted(stateEventId);

            e.CommandId = c.CommandId;


            e.CreatedBy = (string)c.RequesterId;
            e.CreatedAt = ApplicationContext.Current.TimestampService.Now <DateTime>();


            return(e);
        }
        public virtual void Delete(IDeleteProductCategory c)
        {
            IProductCategoryStateDeleted e = Map(c);

            Apply(e);
        }
 void IProductCategoryApplicationService.When(IDeleteProductCategory c)
 {
     this.When((DeleteProductCategoryDto)c);
 }
Beispiel #5
0
 public virtual void When(IDeleteProductCategory c)
 {
     Update(c, ar => ar.Delete(c));
 }