public async Task <ActionResult> Put(Guid bid, [FromBody] ProductGroupDTO productGroup)
        {
            var userName = User.Identity.Name;

            var userId = (await _userRepository.FindUser(userName))?.Id;

            if (!userId.HasValue)
            {
                return(StatusCode(401));
            }

            try
            {
                var basket = await _basketRepository.Get(bid);

                if (basket.OwnerId != userId.Value)
                {
                    return(StatusCode(401));
                }

                var product = await _productRepository.Get(productGroup.ProductId);

                var resultProduct = basket.UpsertItem(product, productGroup.Quantity);
                await _productRepository.Update(productGroup.ProductId, resultProduct);

                await _basketRepository.Update(bid, basket);

                return(NoContent());
            }
            catch (KeyNotFoundException)
            {
                return(NotFound());
            }
        }
Example #2
0
        public Task Put(Guid bid, ProductGroupDTO productGroup)
        {
            var url         = AddresWithBasketId(bid);
            var byteContent = ByteContent(productGroup);

            return(_httpClient.PutAsync(url, byteContent));
        }
Example #3
0
        public ProductGroupDTO Update(ProductGroupDTO updatedRecord)
        {
            try
            {
                string query = @"
                UPDATE ProductGroups
                SET ProductGroupCode = @ProductGroupCode
                ,ProductGroupName = @ProductGroupName
                ,ProductGroupDescription = @ProductGroupDescription
                WHERE ProductGroupID = @ProductGroupID";

                var queryParameters = new DynamicParameters();
                queryParameters.Add("@ProductGroupID", updatedRecord.ProductGroupID);
                queryParameters.Add("@ProductGroupCode", updatedRecord.ProductGroupCode);
                queryParameters.Add("@ProductGroupName", updatedRecord.ProductGroupName);
                queryParameters.Add("@ProductGroupDescription", updatedRecord.ProductGroupDescription);

                int rowsUpdated = Connection.Execute(query, queryParameters, CurrentTrans);
                return((rowsUpdated > 0) ? GetByID(updatedRecord.ProductGroupID) : throw noRecordEX);
            }
            catch (Exception ex)
            {
                throw SqlExceptionHandler.HandleSqlException(ex) ?? ex;
            }
        }
 public static ProductGroup ToModel(this ProductGroupDTO productGroup)
 {
     return(new ProductGroup
     {
         ProductId = productGroup.ProductId,
         Quantity = productGroup.Quantity,
         UnitPrice = productGroup.UnitPrice ?? 0
     });
 }
Example #5
0
 public ProductGroupDTO Update(ProductGroupDTO newModel)
 {
     try
     {
         ProductGroupDTO returnModel = UOW.ProductGroupRepo.Update(newModel);
         UOW.SaveChanges();
         return(returnModel);
     }
     catch (Exception ex)
     {
         UOW.RollbackChanges();
         throw ex;
     }
 }
Example #6
0
        private void bbi_Delete_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            ProductGroupDTO oRow = (ProductGroupDTO)gvc_Group.GetFocusedRow();

            if (oRow != null)
            {
                if (MspTool.get_Question("Kayıt Silinecektir. Onaylıyor musunuz?"))
                {
                    if (oRow.RecId != 0)
                    {
                        var result = _repository.Run <DefinitionsService, ActionResponse <ProductGroupDTO> >(x => x.DeleteProductGroup(oRow.RecId));
                        do_refresh();
                    }
                    else
                    {
                        productGroup.Remove(oRow);
                        gc_Group.RefreshDataSource();
                    }
                }
            }
        }
Example #7
0
 public ActionResult <ProductGroupDTO> Update([FromBody] ProductGroupDTO newModel)
 {
     try { return(_prodGroupManager.Update(newModel)); }
     catch (BaseCustomException ex) { return(BadRequest(ex.Message)); }
 }
 public ProductGroupDTO Update(ProductGroupDTO newModel)
 {
     return(_prodGroupService.Update(newModel));
 }