/// <summary> /// /// </summary> /// <param name="data"></param> /// <returns></returns> public async Task <ProductCategory> Create(ICreateProductCategory data) { var existCode = _context.ProductCategory.Find(f => f.CompanyId == data.CompanyId && f.IsDelete == false && f.CategoryCode == data.CategoryCode).FirstOrDefault(); if (existCode == null) { var productCategory = data.Cast <ProductCategory>(); productCategory.CreatedAt = DateTime.UtcNow; productCategory.IsDelete = false; await _context.ProductCategory.InsertOneAsync(productCategory); return(productCategory); } return(new ProductCategory() { Id = "-1" }); }
protected virtual IProductCategoryStateCreated Map(ICreateProductCategory c) { var stateEventId = new ProductCategoryEventId(c.ProductCategoryId, c.Version); IProductCategoryStateCreated e = NewProductCategoryStateCreated(stateEventId); e.ProductCategoryTypeId = c.ProductCategoryTypeId; e.PrimaryParentCategoryId = c.PrimaryParentCategoryId; e.CategoryName = c.CategoryName; e.Description = c.Description; e.CategoryImageUrl = c.CategoryImageUrl; e.DetailScreen = c.DetailScreen; e.ShowInSelect = c.ShowInSelect; e.AttributeSetId = c.AttributeSetId; e.Active = c.Active; e.CommandId = c.CommandId; e.CreatedBy = (string)c.RequesterId; e.CreatedAt = ApplicationContext.Current.TimestampService.Now <DateTime>(); var version = c.Version; return(e); }
public virtual void Create(ICreateProductCategory c) { IProductCategoryStateCreated e = Map(c); Apply(e); }
void IProductCategoryApplicationService.When(ICreateProductCategory c) { this.When((CreateProductCategoryDto)c); }
public virtual void When(ICreateProductCategory c) { Update(c, ar => ar.Create(c)); }