public async Task <bool> UpdateAsync(AddUpdatePurchaseDto purchaseDto)
        {
            var medicines = purchaseDto.Medicines.Select(x => FromPurchaseMedicineModel(x)).ToList();

            #region validations

            ValidatePurchaseMedicines(medicines);

            #endregion

            #region update filter

            var updateFilter = Builders <Purchase> .Update
                               .Set(x => x.InvoiceNo, purchaseDto.InvoiceNo)
                               .Set(x => x.InvoiceValue, purchaseDto.InvoiceValue)
                               .Set(x => x.InvoiceDate, purchaseDto.InvoiceDate)
                               .Set(x => x.LastPaymentDate, purchaseDto.LastPaymentDate)
                               .Set(x => x.ChequeNo, purchaseDto.ChequeNo)
                               .Set(x => x.ChequeAmount, purchaseDto.ChequeAmount)
                               .Set(x => x.PaidInCash, purchaseDto.PaidInCash)
                               .Set(x => x.ExtraNote, purchaseDto.ExtraNote)
                               .Set(x => x.Medicines, medicines);

            #endregion

            return(await UpdateOneAsync(purchaseDto.InvoiceNo, updateFilter, _userClaims.Id));
        }
        public async Task <string> CreateAsync(AddUpdatePurchaseDto purchaseDto)
        {
            var entity = new Purchase
            {
                InvoiceNo       = purchaseDto.InvoiceNo,
                InvoiceValue    = purchaseDto.InvoiceValue,
                InvoiceDate     = purchaseDto.InvoiceDate,
                LastPaymentDate = purchaseDto.LastPaymentDate,
                ChequeNo        = purchaseDto.ChequeNo,
                ChequeDate      = purchaseDto.ChequeDate,
                ChequeAmount    = purchaseDto.ChequeAmount,
                PaidInCash      = purchaseDto.PaidInCash,
                ExtraNote       = purchaseDto.ExtraNote
            };

            entity.Medicines = purchaseDto.Medicines.Select(x => FromPurchaseMedicineModel(x)).ToList();

            entity.Medicines.ForEach(x =>
            {
                x.Id = ObjectId.GenerateNewId().ToString();
            });

            #region validations

            ValidatePurchaseMedicines(entity.Medicines);

            #endregion

            return(await AddOneAsync(entity, _userClaims.Id));
        }