Beispiel #1
0
        /// <summary>
        /// DeleteEntity the tag in the system with the given tag id
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public TagTypeDto Delete(int id)
        {
            return(ActionVerbConfigService.WrapAction(() =>
            {
                var tagDeleteActionResult = _tagTypesLogic.DeleteTag(id);

                if (tagDeleteActionResult.Success)
                {
                    return AutoMapper.Mapper.Map <TagType, TagTypeDto>(tagDeleteActionResult.Data);
                }

                throw new HttpResponseException(ResponseMessageBuilder.BuildMessageFromActionResult(tagDeleteActionResult));
            }));
        }
Beispiel #2
0
        public ProductDto Activate([FromBody] int id)
        {
            return(ActionVerbConfigService.WrapAction(() =>
            {
                var activateResult = _productLogic.Activate(id);

                if (activateResult.Success)
                {
                    var productDto = AutoMapper.Mapper.Map <Product, ProductDto>(activateResult.Data);
                    return productDto;
                }

                throw new HttpResponseException(ResponseMessageBuilder.BuildMessageFromActionResult(activateResult));
            }));
        }
Beispiel #3
0
        // PUT api/products/5
        public ProductEditObject Put(ProductEditObject product)
        {
            return(ActionVerbConfigService.WrapAction(() =>
            {
                var updateResult = _productLogic.Update(product);

                if (updateResult.Success)
                {
                    CheckAndDeleteImages(product);

                    return updateResult.Data;
                }

                throw new HttpResponseException(ResponseMessageBuilder.BuildMessageFromActionResult(updateResult));
            }));
        }
Beispiel #4
0
        public ProductAdminDto Post(ProductOperationObject product)
        {
            return(ActionVerbConfigService.WrapAction(() =>
            {
                var createResult = _productLogic.Create(product);

                if (createResult.Success)
                {
                    var createdProduct = createResult.Data;
                    var adminDto = AutoMapper.Mapper.Map <ProductAdminDto>(createdProduct);
                    return adminDto;
                }

                throw new HttpResponseException(ResponseMessageBuilder.BuildMessageFromActionResult(createResult));
            }));
        }
Beispiel #5
0
        public ManufacturerDto Delete(int id)
        {
            return(ActionVerbConfigService.WrapAction(() =>
            {
                var result = _manufacturerLogic.Delete(id);

                if (result.Success)
                {
                    var deletedManufacturer = result.Data;
                    var deletedManufacturerDto =
                        AutoMapper.Mapper.Map <Manufacturer, ManufacturerDto>(deletedManufacturer);
                    return deletedManufacturerDto;
                }

                throw new HttpResponseException(ResponseMessageBuilder.BuildMessageFromActionResult(result));
            }));
        }
        public CategoryHirearchyDto Post(CategoryHirearchyDto root)
        {
            return(ActionVerbConfigService.WrapAction(() =>
            {
                var domainCategoryRoot = AutoMapper.Mapper.Map <CategoryHirearchyDto, Category>(root);

                var actionResult = _categoryLogic.UpdateCategoryHirearchy(domainCategoryRoot);

                if (actionResult.Success)
                {
                    CleanupCategoryImages();
                    return AutoMapper.Mapper.Map <Category, CategoryHirearchyDto>(actionResult.Data);
                }

                throw new HttpResponseException(ResponseMessageBuilder.BuildMessageFromActionResult(actionResult));
            }));
        }
Beispiel #7
0
        public async Task <HttpResponseMessage> Post()
        {
            if (ActionVerbConfigService.VerbsDisabled())
            {
                ActionVerbConfigService.ThrowDisabledVerb();
                return(new HttpResponseMessage());
            }

            if (!Request.Content.IsMimeMultipartContent())
            {
                Request.CreateResponse(HttpStatusCode.UnsupportedMediaType);
            }

            var storeResult = await new FileManager().Process(Request);

            return(Request.CreateResponse(HttpStatusCode.OK, storeResult));
        }
Beispiel #8
0
        /// <summary>
        /// Recieve a tag type dto from the body with a already existing id and update
        /// the tag information.
        ///
        /// Returns the updated tag back to the client or null/exception if update failed
        /// </summary>
        /// <param name="updatedTag"></param>
        /// <returns></returns>
        public TagTypeDto Put([FromBody] TagTypeDto updatedTag)
        {
            return(ActionVerbConfigService.WrapAction(() =>
            {
                var tagTypeDomainObject = AutoMapper.Mapper.Map <TagTypeDto, TagType>(updatedTag);

                var tagUpdateActionResult = _tagTypesLogic.UpdateTag(tagTypeDomainObject);

                if (tagUpdateActionResult.Success)
                {
                    var updatedTagDto = AutoMapper.Mapper.Map <TagType, TagTypeDto>(tagUpdateActionResult.Data);
                    return updatedTagDto;
                }

                throw new HttpResponseException(ResponseMessageBuilder.BuildMessageFromActionResult(tagUpdateActionResult));
            }));
        }
Beispiel #9
0
        public ManufacturerDto Put(ManufacturerDto data)
        {
            return(ActionVerbConfigService.WrapAction(() =>
            {
                Manufacturer manufacturer = AutoMapper.Mapper.Map <ManufacturerDto, Manufacturer>(data);

                var result = _manufacturerLogic.Update(manufacturer);

                if (result.Success)
                {
                    var createdManufacturer = result.Data;
                    var createdDto = AutoMapper.Mapper.Map <Manufacturer, ManufacturerDto>(createdManufacturer);
                    return createdDto;
                }

                throw new HttpResponseException(ResponseMessageBuilder.BuildMessageFromActionResult(result));
            }));
        }
Beispiel #10
0
        /// <summary>
        /// Recieve a tag type dto from the body and create a new tag from the
        /// dto.
        ///
        /// Return the newly created tag including its id to the client
        /// </summary>
        /// <param name="newTag"></param>
        /// <returns></returns>
        public TagTypeDto Post([FromBody] TagTypeDto newTag)
        {
            return(ActionVerbConfigService.WrapAction(() =>
            {
                // map from the new tag to a TagType domain obhject using auto mapper
                var tagTypeDomainObject = AutoMapper.Mapper.Map <TagTypeDto, TagType>(newTag);

                var tagCreateActionResult = _tagTypesLogic.CreateTagForCategory(tagTypeDomainObject, newTag.CategoryId);

                if (tagCreateActionResult.Success)
                {
                    // map the dto of the newly created tag returned form the service to an apropriate tag dto
                    // which we will return back to the client
                    var storedTagDto = AutoMapper.Mapper.Map <TagType, TagTypeDto>(tagCreateActionResult.Data);
                    return storedTagDto;
                }

                throw new HttpResponseException(
                    ResponseMessageBuilder.BuildMessageFromActionResult(tagCreateActionResult));
            }));
        }