public IActionResult DeleteProductType([FromBody] ProductTypeDTO request)
        {
            var response = new OperationResponse <ICollection>();

            try
            {
                var result = _categoriesService.DeleteProductType(request.Tasks);
                if (result.Any(fn => !string.IsNullOrEmpty(fn.Message)))
                {
                    response.State = ResponseState.ValidationError;
                    response.Data  = result.ToList();
                    return(new JsonResult(response));
                }
                else
                {
                    response.State = ResponseState.Success;
                }
            }
            catch (Exception exception)
            {
                response.State = ResponseState.Error;
                response.Messages.Add(exception.Message);
                _logger.LogError(exception, "Error in DeleteProductType ==>" + exception.StackTrace, request);
            }
            return(new JsonResult(response));
        }
Example #2
0
        public virtual ProductTypeDTO Save(ProductTypeDTO dto)
        {
            var entity    = Mapper.Map <ProductType>(dto);
            var savedItem = _productTypeRepository.Save(entity);

            return(Mapper.Map <ProductTypeDTO>(savedItem));
        }
        public async Task <ActionResult> pvwAddProductType([FromBody] ProductTypeDTO _sarpara)

        {
            ProductTypeDTO _ProductType = new ProductTypeDTO();

            try
            {
                string     baseadress = config.Value.urlbase;
                HttpClient _client    = new HttpClient();
                _client.DefaultRequestHeaders.Add("Authorization", "Bearer " + HttpContext.Session.GetString("token"));
                var result = await _client.GetAsync(baseadress + "api/ProductType/GetProductTypeById/" + _sarpara.ProductTypeId);

                string valorrespuesta = "";
                if (result.IsSuccessStatusCode)
                {
                    valorrespuesta = await(result.Content.ReadAsStringAsync());
                    _ProductType   = JsonConvert.DeserializeObject <ProductTypeDTO>(valorrespuesta);
                }

                if (_ProductType == null)
                {
                    _ProductType = new ProductTypeDTO();
                }
            }
            catch (Exception ex)
            {
                _logger.LogError($"Ocurrio un error: { ex.ToString() }");
                throw ex;
            }



            return(PartialView(_ProductType));
        }
Example #4
0
        // Properties and Types
        private void ImportProductTypes()
        {
            Header("Importing Product Types");

            Api oldProxy = GetOldStoreBV6Proxy();
            ApiResponse <List <ProductTypeDTO> > types = oldProxy.ProductTypesFindAll();

            foreach (ProductTypeDTO old in types.Content)
            {
                wl("Item: " + old.ProductTypeName);

                ProductTypeDTO pt       = old;
                Api            bv6proxy = GetBV6Proxy();
                var            res      = bv6proxy.ProductTypesCreate(pt);
                if (res != null)
                {
                    if (res.Errors.Count() > 0)
                    {
                        DumpErrors(res.Errors);
                        wl("FAILED");
                    }
                    else
                    {
                        //TODO: Migrate Properties for Types
                        //MigratePropertiesForType(pt.Bvin);
                        wl("SUCCESS");
                    }
                }
            }
        }
Example #5
0
        public ProductType Post([FromBody] ProductTypeDTO value)
        {
            TryValidateModel(value);
            var productType = this.service.Create(this.mapper.Map <ProductType>(value));

            return(this.mapper.Map <ProductType>(productType));
        }
        public async Task <ActionResult <ProductTypeDTO> > PostProductType(ProductTypeDTO productType)
        {
            _context.ProductTypes.Add(DTOToProductType(productType));
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetProductType", new { }, productType));
        }
 public void Put(string id, [FromBody] ProductTypeDTO value)
 {
     var productType = this.service.Get(id);
     TryValidateModel(value);
     mapper.Map<ProductTypeDTO, ProductType>(value, productType);
     service.Update(productType);
 }
        public bool getDataProductType()
        {
            try
            {
                string        sql    = "Select * from ProductType";
                SqlDataReader reader = ReadData(sql);

                while (reader.Read())
                {
                    ProductTypeDTO data = new ProductTypeDTO();
                    data.ProductTypeID = reader["ProductTypeID"].ToString();
                    data.ProductName   = reader["ProductTypeName"].ToString();
                    data.CommodityID   = reader["CommodityID"].ToString();
                    data.Quantity      = Convert.ToInt32(reader["QuantityProduct"]);

                    list.Add(data);
                }
            }
            catch (Exception exc)
            {
                exc.ToString();
                return(false);
            }
            finally
            {
                CloseConnection();
            }
            return(true);
        }
        private async Task<ImportValidationResultInfo> MapAndValidate(ProductTypeDTO dto, int index)
        {
            return await Task.Run(() =>
            {
                if (dto == null) return null;
                var entity = _mappingService.Map(dto);
                var exist = _ctx.tblProductType.FirstOrDefault(p => p.name.ToLower() == dto.Name.ToLower());

                entity.Id = exist == null ? Guid.NewGuid() : exist.id;

                var res = _repository.Validate(entity);
                var vResult = new ImportValidationResultInfo()
                {
                    Results = res.Results,
                    Description =
                        string.Format("Row-{0} name or code=>{1}", index,
                                      entity.Name ?? entity.Code),
                    Entity = entity
                };
                return vResult;

            });


        }
Example #10
0
        /// <summary>
        ///     Allows the REST API to create or update a product type
        /// </summary>
        /// <param name="parameters">
        ///     Parameters passed in the URL of the REST API call. If there is a first parameter found in the
        ///     URL, the method will assume it is the product type ID (bvin) and that this is an update, otherwise it assumes to
        ///     create a product type.
        /// </param>
        /// <param name="querystring">Name/value pairs from the REST API call querystring. This is not used in this method.</param>
        /// <param name="postdata">Serialized (JSON) version of the ProductTypeDTO object</param>
        /// <returns>ProductTypeDTO - Serialized (JSON) version of the ProductType</returns>
        public override string PostAction(string parameters, NameValueCollection querystring, string postdata)
        {
            var data = string.Empty;
            var bvin = FirstParameter(parameters);

            //
            // <site Url>/producttypes/<guid>/properties/<propertyid>/<sortOrder>
            //
            var isProperty = GetParameterByIndex(1, parameters);

            if (isProperty.Trim().ToLowerInvariant() == "properties")
            {
                var response2 = new ApiResponse <bool>();

                var  propertyIds = GetParameterByIndex(2, parameters);
                long propertyId  = 0;
                long.TryParse(propertyIds, out propertyId);

                response2.Content = HccApp.CatalogServices.ProductTypeAddProperty(bvin, propertyId);
                data = Json.ObjectToJson(response2);
            }
            else
            {
                var            response   = new ApiResponse <ProductTypeDTO>();
                ProductTypeDTO postedItem = null;
                try
                {
                    postedItem = Json.ObjectFromJson <ProductTypeDTO>(postdata);
                }
                catch (Exception ex)
                {
                    response.Errors.Add(new ApiError("EXCEPTION", ex.Message));
                    return(Json.ObjectToJson(response));
                }

                var item = new ProductType();
                item.FromDto(postedItem);

                if (bvin == string.Empty)
                {
                    if (HccApp.CatalogServices.ProductTypes.Create(item))
                    {
                        bvin = item.Bvin;
                    }
                }
                else
                {
                    HccApp.CatalogServices.ProductTypes.Update(item);
                }
                var resultItem = HccApp.CatalogServices.ProductTypes.Find(bvin);
                if (resultItem != null)
                {
                    response.Content = resultItem.ToDto();
                }
                data = Json.ObjectToJson(response);
            }

            return(data);
        }
 public static ProductType ToModel(this ProductTypeDTO ObjectToConvert)
 {
     return(new ProductType()
     {
         ID = ObjectToConvert.ID,
         Descripton = ObjectToConvert.Descripton
     });
 }
Example #12
0
        public void UpdateProductType(ProductTypeDTO productTypeDTO)
        {
            var productType = productTypeRepository.GetBy(productTypeDTO.IDLSP);

            productTypeDTO.MappingProductType(productType);

            productTypeRepository.Update(productType);
        }
        public ActionResult UpdateProductType(ProductTypeDTO PT)
        {
            int Cnt = mmsMasters.UpdateProductType(PT);

            return(new JsonResult {
                Data = Cnt, JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }
        public ActionResult CheckProducttype(ProductTypeDTO PT)
        {
            int c = mmsMasters.CheckProducttype(PT);

            return(new JsonResult {
                Data = c, JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }
Example #15
0
        public ProductTypeDTO Update(ProductTypeDTO productType)
        {
            var oldValue = new ProductType();

            _mapper.Map(productType, oldValue);
            _unitOfWork.ProductTypeRepository.Update(oldValue);
            _unitOfWork.SaveChanges();
            return(productType);
        }
Example #16
0
        public ProductTypeDTO Insert(ProductTypeDTO productTypeDTO)
        {
            var productType = _mapper.Map(productTypeDTO, new ProductType());

            _unitOfWork.ProductTypeRepository.Add(productType);
            _unitOfWork.SaveChanges();
            productTypeDTO.Id = productType.Id;
            return(productTypeDTO);
        }
Example #17
0
        public ProductTypeDTO Edit(int id, ProductTypeDTO entity)
        {
            _context.Entry(_context.ProductTypes.FirstOrDefault(x => x.Id == id) !).CurrentValues
            .SetValues(entity);
            var productType    = _context.ProductTypes.Find(id);
            var productTypeDto = _mapper.Map <ProductTypeDTO>(productType);

            return(productTypeDto);
        }
 public ProductType DTOToProductType(ProductTypeDTO productType)
 {
     return(new ProductType()
     {
         id = productType.Id,
         name = productType.Name,
         canBeInsured = productType.canBeInsured
     });
 }
 public static ProductType MappingProductType(this ProductTypeDTO productTypeDTO)
 {
     var productType = new ProductType
     {
         IDLSP = productTypeDTO.IDLSP,
         Name = productTypeDTO.Name,
         Filter = productTypeDTO.Filter,
     };
     return productType;
 }
Example #20
0
        public IActionResult Create([FromBody] ProductTypeDTO productTypeDTO)
        {
            ProductType productType = new ProductType();

            productType.ProductTypeName = productTypeDTO.ProductTypeName;
            var productTypeEntity = _productTypesService.Create(productType);
            var productTypes      = _mapper.Map <ProductTypeDTO>(productTypeEntity);

            return(Ok(productType));
        }
 public static ProductTypeDTO MappingProductTypeDto(this ProductType productType)
 {
     var productTypeDTO = new ProductTypeDTO
     {
         IDLSP = productType.IDLSP,
         Name = productType.Name,
         Filter = productType.Filter,
     };
     return productTypeDTO;
 }
Example #22
0
        public async Task <ProductTypeDTO> EditAsync(int id, ProductTypeDTO entity)
        {
            _context.Entry(await _context.Photos.FirstOrDefaultAsync(x => x.Id == id) !).CurrentValues
            .SetValues(entity);
            var productType = await _context.ProductTypes.FindAsync(id);

            var productTypeDto = _mapper.Map <ProductTypeDTO>(productType);

            return(productTypeDto);
        }
        public ActionResult SaveProductType(ProductTypeDTO PT)
        {
            PT.statusid  = 1;
            PT.createdby = Convert.ToInt64(Session["UserId"]);
            int Count = mmsMasters.SaveProductType(PT);

            return(new JsonResult {
                Data = Count, JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }
Example #24
0
        public async Task <ActionResult> AddProductType(ProductTypeDTO productTypeDTO)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var productType = await this.productServices.AddProductTypeAsync(productTypeDTO);

            return(CreatedAtAction(nameof(GetProductTypeById), new { id = productType.Id }, productType));
        }
Example #25
0
        public ServiceResult Create(ProductTypeDTO model)
        {
            var entity = new ProductType();

            Mapper.Map(model, entity);

            _productType.Add(entity);
            _Context.SaveChanges();

            return(ServiceResult.Okay());
        }
Example #26
0
        public IActionResult Create(ProductTypeDTO model)
        {
            var result = _productTypeRepository.Create(model);

            TempData.AddResult(result);
            if (model.ParentId.HasValue)
            {
                return(RedirectToAction(nameof(SubGroup), new { model.ParentId }));
            }
            return(RedirectToAction(nameof(Index)));
        }
Example #27
0
        // DTO
        public ProductTypeDTO ToDto()
        {
            ProductTypeDTO dto = new ProductTypeDTO();

            dto.Bvin            = this.Bvin;
            dto.StoreId         = this.StoreId;
            dto.IsPermanent     = this.IsPermanent;
            dto.LastUpdated     = this.LastUpdated;
            dto.ProductTypeName = this.ProductTypeName;

            return(dto);
        }
 public LogicResult <ProductTypeDTO> Save(ProductTypeDTO entity)
 {
     try
     {
         var dto = _productTypeBusinessLogic.Save(entity);
         return(LogicResult <ProductTypeDTO> .Succeed(dto));
     }
     catch (Exception exception)
     {
         return(LogicResult <ProductTypeDTO> .Failure(exception));
     }
 }
Example #29
0
        /// <summary>
        ///     Allows you to convert the current product type object to the DTO equivalent for use with the REST API
        /// </summary>
        /// <returns>A new instance of ProductTypeDTO</returns>
        public ProductTypeDTO ToDto()
        {
            var dto = new ProductTypeDTO();

            dto.Bvin            = Bvin;
            dto.StoreId         = StoreId;
            dto.IsPermanent     = IsPermanent;
            dto.LastUpdated     = LastUpdated;
            dto.ProductTypeName = ProductTypeName;
            dto.TemplateName    = TemplateName;

            return(dto);
        }
Example #30
0
        public void FromDto(ProductTypeDTO dto)
        {
            if (dto == null)
            {
                return;
            }

            this.Bvin            = dto.Bvin ?? string.Empty;
            this.StoreId         = dto.StoreId;
            this.IsPermanent     = dto.IsPermanent;
            this.LastUpdated     = dto.LastUpdated;
            this.ProductTypeName = dto.ProductTypeName ?? string.Empty;
        }
        public async Task <ProductType> AddProductTypeAsync(ProductTypeDTO inputModel)
        {
            var productType = new ProductType()
            {
                Name = inputModel.Name
            };

            await this.dbContext.ProductType.AddAsync(productType);

            await this.dbContext.SaveChangesAsync();

            return(productType);
        }
 private ProductTypeDTO Map(tblProductType tbl)
 {
     var dto = new ProductTypeDTO
                   {
                       MasterId = tbl.id,
                       DateCreated = tbl.IM_DateCreated,
                       DateLastUpdated = tbl.IM_DateLastUpdated,
                       StatusId = tbl.IM_Status,
                       Name = tbl.name,
                       Code = tbl.code,
                       Description = tbl.Description
                   };
     return dto;
 }
Example #33
0
 public ProductType Map(ProductTypeDTO dto)
 {
     if (dto == null) return null;
     var productType = Mapper.Map<ProductTypeDTO, ProductType>(dto);
     return productType;
 }