コード例 #1
0
        public ProductRES ProductDTtoRES()
        {
            ProductRES productRES = new ProductRES()
            {
                Id            = Id,
                ProductStatus = ProductStatus,
                ProductName   = ProductName,
                Categories    = ProductCategories != null?ProductCategories.Select(x => x.CategoryToRES()).ToList() : null,
                                    CreateDate = CreateDate,
                                    CreateUser = CreateUser != null?CreateUser.AppUserDTtoRES() : null,
                                                     Discount              = Discount,
                                                     DiscountAmount        = DiscountAmount,
                                                     DiscountFinishDate    = DiscountFinishDate,
                                                     DiscountStartDate     = DiscountStartDate,
                                                     MainImage             = MainImage,
                                                     ProductImageGalleries = ProductImageGalleries != null?ProductImageGalleries.Select(x => x.ProductImageGalleryDTtoRES()).ToList() : null,
                                                                                 UpdateDate = UpdateDate,
                                                                                 UpdateUser = UpdateUser != null?UpdateUser.AppUserDTtoRES() : null,
                                                                                                  ProductAmountTypes = ProductAmountTypes.Select(x => x.ProductAmountTypeDTtoRES()).ToList(),
                                                                                                  LongDescription    = LongDescription,
                                                                                                  ShortDescription   = ShortDescription,
            };

            return(productRES);
        }
コード例 #2
0
        public IActionResult GetProductDetail(int id)
        {
            if (id != 0)
            {
                errorModels = new List <ErrorModel>();
                OperationResult operationResult_products = _uow.Products.GetProductDetail(id);
                if (operationResult_products.IsSuccess)
                {
                    Product product = (Product)operationResult_products.ReturnObject;

                    ProductRES productRES = product.ProductDTtoRES();

                    apiResponsive = new ApiResponsive
                    {
                        IsSucces     = true,
                        ErrorContent = null,
                        ReturnObject = productRES
                    };

                    return(Ok(apiResponsive));
                }
                else
                {
                    ErrorModel errorModel2 = new ErrorModel()
                    {
                        ErrorCode    = MessageNumber.UrunGetirilemedi.ToString(),
                        ErrorMessage = _localizer["UrunGetirilemedi"]
                    };

                    errorModels.Add(errorModel2);

                    apiResponsive = new ApiResponsive()
                    {
                        IsSucces     = false,
                        ReturnObject = null,
                        ErrorContent = errorModels
                    };

                    return(BadRequest(apiResponsive));
                }
            }

            ErrorModel errorModel3 = new ErrorModel()
            {
                ErrorCode    = MessageNumber.ParametrelerHatali.ToString(),
                ErrorMessage = _localizer["ParametrelerHatali"]
            };

            errorModels.Add(errorModel3);

            apiResponsive = new ApiResponsive()
            {
                IsSucces     = false,
                ReturnObject = null,
                ErrorContent = errorModels
            };

            return(BadRequest(apiResponsive));
        }