示例#1
0
        public VendorDto GetById(int vendorId)
        {
            var result       = _vendorRepository.GetById(vendorId);
            var mappedResult = _mapper.Map <VendorDto>(result);

            return(mappedResult);
        }
示例#2
0
        public async Task <object> DetailsAddressAndRep(int id)
        {
            dynamic AdressAndrepDetails = new ExpandoObject();
            dynamic vendor         = new ExpandoObject();
            dynamic vendor_address = new ExpandoObject();
            dynamic vendor_Rep     = new ExpandoObject();
            dynamic vendor_Note    = new ExpandoObject();

            try
            {
                vendor = await _VendorRepo.GetById(id);

                vendor_address = await _VendorRepo.GetVendorDetailsAddress(id);

                vendor_Rep = await _VendorRepo.GetVendorDetailsRep(id);

                AdressAndrepDetails.Vendor    = vendor;
                AdressAndrepDetails.Addresses = vendor_address;
                AdressAndrepDetails.Reps      = vendor_Rep;
            }
            catch (Exception ex)
            {
                var logger = _loggerFactory.CreateLogger("internal_error_log");
                logger.LogInformation("Problem happened in selecting the data for listpageviewAsync with message" + ex.Message);
            }

            return(AdressAndrepDetails);
        }
示例#3
0
        public async Task <VendorDto> GetOne(Guid id)
        {
            var vendor = await _vendorRepository.GetById(id);

            if (vendor == null)
            {
                throw new KeyNotFoundException($"Vendor with id: {id} not found.");
            }

            return(_mapper.Map <Vendor, VendorDto>(vendor));
        }
        public async Task <VendorResponse> GetVendorById(GetVendorRequest request, string email)
        {
            if (request?.Id == null)
            {
                throw new ArgumentNullException();
            }
            var user = await _userRepository.GetByEmailAsync(email);

            var vendor = await _vendorRepository.GetById(request.Id, user.Id);

            return(_vendorMapper.Map(vendor));
        }
        public IActionResult EditVendor(int id)
        {
            var vendor = _vendorRepo.GetById(id);

            if (vendor != null)
            {
                ViewData["Vendor"] = vendor;
                return(View());
            }

            return(RedirectToAction("Index"));
        }
示例#6
0
        public GridResultDTO GetById(int id)
        {
            var           data      = _VendorRepository.GetById(id);
            GridResultDTO VendorDTO = new GridResultDTO()
            {
                Id         = data.Id,
                VendorName = data.VendorName,
                Title      = data.Title,
                IsDeleted  = data.IsDeleted,
                Date       = data.Date,
                Tag        = _VendorRepository.GetAllTags(id).Select(y => new TagDTO
                {
                    Name = y.Name
                }).ToList()
            };

            return(VendorDTO);
        }
        public async Task <ActionResult <VendorDTO> > Delete(Guid id)
        {
            var vendor = await _vendorRespository.GetById(id);

            if (vendor == null)
            {
                return(NotFound());
            }

            var result = await _vendorService.Remove(id);

            return(CustomResponse());
        }
示例#8
0
        public bool Update(VendorUpdateDTO dto)
        {
            bool updated = false;

            var vendor = _repository.GetById(dto.Id);

            foreach (var item in dto.Tags)
            {
                var getTagVendorIdById = new Tag()
                {
                    VendorId = dto.Id
                };
                _tagRepository.DeleteById(getTagVendorIdById.VendorId);
            }

            var tagList = new List <Tag>();

            foreach (var item in dto.Tags)
            {
                var tags = new Tag()
                {
                    Name  = item.Name,
                    Value = item.Value
                };
                tagList.Add(tags);
            }

            vendor.Name  = dto.Name;
            vendor.Title = dto.Title;
            vendor.Date  = dto.Date;
            vendor.Tags  = tagList;

            int inserted = _repository.Update(vendor);

            if (inserted > 0)
            {
                updated = true;
            }
            return(updated);
        }
 public Vendor GetById(long id)
 {
     return(_vendorRepository.GetById(id));
 }
示例#10
0
        public async Task <ProductDto> Create(Guid userId, ProductForCreationDto productForCreationDto)
        {
            var vendor = await _vendorRepository.GetById(productForCreationDto.VendorId);

            if (vendor == null)
            {
                throw new KeyNotFoundException($"Vendor with id: {productForCreationDto.VendorId} not found.");
            }

            var category = await _categoryRepository.GetById(productForCreationDto.CategoryId);

            if (category == null)
            {
                throw new KeyNotFoundException($"Category with id: {productForCreationDto.CategoryId} not found.");
            }

            var product = new Product()
            {
                Name              = productForCreationDto.Name,
                Description       = productForCreationDto.Description,
                Code              = productForCreationDto.Code,
                CategoryId        = productForCreationDto.CategoryId,
                VendorId          = productForCreationDto.VendorId,
                Brand             = productForCreationDto.Brand,
                MinimumStock      = productForCreationDto.MinimumStock,
                Stock             = 0,
                UnitOfMeasurement = productForCreationDto.UnitOfMeasurement,
                CreatedBy         = userId
            };

            product = await _productRepository.Add(product);

            //PurchasePrice
            var purchasePrice = new Price()
            {
                Value     = productForCreationDto.PurchasePrice.Value,
                DateTime  = DateTime.Now,
                ProductId = product.Id,
                PriceType = ePriceTypes.PurchasePrice
            };

            await _priceRepository.Add(purchasePrice);

            //SalePrice
            var salePrice = new Price()
            {
                Value     = productForCreationDto.SalePrice.Value,
                DateTime  = DateTime.Now,
                ProductId = product.Id,
                PriceType = ePriceTypes.SalePrice
            };

            await _priceRepository.Add(salePrice);

            await _productRepository.CommitAsync();

            await _priceRepository.CommitAsync();

            var productDto = _mapper.Map <Product, ProductDto>(product);

            productDto.PurchasePrice = _mapper.Map <Price, PriceDto>(purchasePrice);
            productDto.SalePrice     = _mapper.Map <Price, PriceDto>(salePrice);

            return(productDto);
        }
示例#11
0
 public async Task <RVendor> GetFromDb(string id)
 {
     return(await _vendorRepository.GetById(id));
 }
示例#12
0
        public async Task <ProductEntryDto> Create(Guid userId, ProductEntryForCreationDto productEntryForCreationDto)
        {
            try
            {
                if (productEntryForCreationDto.IsEntry)
                {
                    var vendor = await _vendorRepository.GetById(productEntryForCreationDto.VendorId.Value);

                    if (vendor == null)
                    {
                        throw new KeyNotFoundException($"Vendor with id: {productEntryForCreationDto.VendorId.Value} not found.");
                    }
                }

                ProductEntry productEntry = new ProductEntry()
                {
                    Date         = productEntryForCreationDto.Date.ToLocalTime(),
                    IsEntry      = productEntryForCreationDto.IsEntry,
                    VendorId     = productEntryForCreationDto.VendorId,
                    Cost         = productEntryForCreationDto.Cost,
                    PaymentType  = productEntryForCreationDto.PaymentType,
                    Observations = productEntryForCreationDto.Observations,
                    CreatedBy    = userId
                };

                productEntry = await _productEntryRepository.Add(productEntry);

                //ProductEntryLines
                foreach (var pelDto in productEntryForCreationDto.ProductEntryLines)
                {
                    var product = await _productRepository.GetById(pelDto.ProductId);

                    if (product == null)
                    {
                        throw new KeyNotFoundException($"Product with id: {pelDto.ProductId} not found.");
                    }

                    var productEntryLine = new ProductEntryLine()
                    {
                        Quantity       = pelDto.Quantity,
                        ProductId      = pelDto.ProductId,
                        ProductEntryId = productEntry.Id,
                        CreatedBy      = userId
                    };

                    productEntryLine = await _productEntryLineRepository.Add(productEntryLine);

                    productEntry.ProductEntryLines.Add(productEntryLine);

                    product.Stock += pelDto.Quantity * (productEntry.IsEntry ? 1 : -1);
                    await _productRepository.Update(product);
                }

                await _productEntryRepository.CommitAsync();

                await _productEntryLineRepository.CommitAsync();

                await _productRepository.CommitAsync();

                var productEntryDto = _mapper.Map <ProductEntry, ProductEntryDto>(productEntry);

                return(productEntryDto);
            }
            catch (Exception e)
            {
                throw e;
            }
        }