예제 #1
0
        public BaseViewModel <ProductViewModel> UpdateProduct(Guid id, UpdateProductRequestViewModel product)
        {
            var entity = _repository.GetById(id);

            if (entity == null || entity.IsDelete)
            {
                return(new BaseViewModel <ProductViewModel>
                {
                    StatusCode = HttpStatusCode.NotFound,
                    Description = MessageHandler.CustomErrMessage(ErrMessageConstants.NOTFOUND),
                    Code = ErrMessageConstants.NOTFOUND
                });
            }

            entity = _mapper.Map(product, entity);
            entity.SetDefaultUpdateValue(_repository.GetUsername());
            _repository.Update(entity);
            var result = new BaseViewModel <ProductViewModel>
            {
                Data = _mapper.Map <ProductViewModel>(entity),
            };

            Save();

            return(result);
        }
예제 #2
0
        public ActionResult <BaseViewModel <ProductViewModel> > PutProduct([CheckGuid(Property = "LocationId")] string id, [FromBody] UpdateProductRequestViewModel product)
        {
            var guidID = new Guid(id);

            product.Id = guidID;
            var result = _productService.UpdateProduct(guidID, product);

            this.HttpContext.Response.StatusCode = (int)result.StatusCode;
            return(result);
        }