Beispiel #1
0
        public async Task CreateProductGroupDetail(CreateProductGroupDetailInput input)
        {
            var ProductGrpDetail = input.MapTo <ProductGroupDetail>();

            var productmax = _ProductGroupDetailRepository.GetAll().Where(p => p.ProductGroupId == input.ProductGroupId);
            var maxorderby = productmax.Where(a => a.OrderBy == productmax.Max(x => x.OrderBy)).FirstOrDefault();

            if (maxorderby == null)
            {
                ProductGrpDetail.OrderBy  = 0;
                ProductGrpDetail.ReturnBy = 0;
            }
            else
            {
                ProductGrpDetail.OrderBy  = maxorderby.OrderBy + 1;
                ProductGrpDetail.ReturnBy = maxorderby.OrderBy + 1;
            }
            var val = _ProductGroupDetailRepository
                      .GetAll().Where(p => p.AttributeGroupId == input.AttributeGroupId && p.ProductGroupId == input.ProductGroupId).FirstOrDefault();

            if (val == null)
            {
                await _ProductGroupDetailRepository.InsertAsync(ProductGrpDetail);
            }
            else
            {
                throw new UserFriendlyException("Ooops!", "This data already exixts '");
            }
        }
Beispiel #2
0
 public async Task CreateOrUpdateProductGroupDetail(CreateProductGroupDetailInput input)
 {
     if (input.Id != 0)
     {
         await UpdateProductGroupDetail(input);
     }
     else
     {
         await CreateProductGroupDetail(input);
     }
 }
Beispiel #3
0
        public async Task UpdateProductGroupDetail(CreateProductGroupDetailInput input)
        {
            var ProductGrpDetail = input.MapTo <ProductGroupDetail>();
            var val = _ProductGroupDetailRepository
                      .GetAll().Where(p => p.AttributeGroupId == input.AttributeGroupId && p.ProductGroupId == input.ProductGroupId && p.Id != input.Id).FirstOrDefault();

            if (val == null)
            {
                ProductGrpDetail.LastModificationTime = DateTime.Now;
                await _ProductGroupDetailRepository.UpdateAsync(ProductGrpDetail);
            }
            else
            {
                throw new UserFriendlyException("Ooops!", "This data already exixts '");
            }
        }