Esempio n. 1
0
 public void Put(UpdatePayment request)
 {
     using (var db = DbConnection.Open())
     {
         db.Update(request.Payment);
     }
 }
Esempio n. 2
0
        private async void OnOk()
        {
            await ValidateAsync();

            if (HasErrors)
            {
                return;
            }

            Entities.Transaction selectedTransaction = SelectedTransaction;
            SelectedTransaction.Payment += UpdatePayment.GetValueOrDefault();
            _context.SaveChanges();
            UpdatePayment = null;
            LoadData();
            if (_isByCustomer)
            {
                Transactions        = _originalTransactions.Where(c => c.Customer.Id == SelectedCustomer.Id).ToList();
                SelectedTransaction = selectedTransaction;
            }
            else
            {
                Transactions        = _originalTransactions;
                SelectedTransaction = selectedTransaction;
            }
            UpdateCommand.RaiseCanExecuteChanged();
            CalculateTransaction();
            DialogHost.CloseDialogCommand.Execute(this, null);
        }
Esempio n. 3
0
        private void dgvData_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            int id = (int)dgvData[0, e.RowIndex].Value;

            switch (Name)
            {
            case "dgv" + ClientName:
                string       name          = (string)dgvData[1, e.RowIndex].Value;
                string       adress        = (string)dgvData[2, e.RowIndex].Value;
                string       phone         = (string)dgvData[3, e.RowIndex].Value;
                string       requisites    = (string)dgvData[4, e.RowIndex].Value;
                string       contactPerson = (string)dgvData[5, e.RowIndex].Value;
                UpdateClient updateClient  = new UpdateClient(id, name, adress, phone, requisites, contactPerson);
                updateClient.ShowDialog();
                break;

            case "dgv" + ContractName:
                DateTime       conclusionDate = (DateTime)dgvData[1, e.RowIndex].Value;
                int            clientId       = (int)dgvData[2, e.RowIndex].Value;
                UpdateContract updateContract = new UpdateContract(id, conclusionDate, clientId);
                updateContract.ShowDialog();
                break;

            case "dgv" + PaymentName:
                int           sum           = (int)dgvData[1, e.RowIndex].Value;
                DateTime      date          = (DateTime)dgvData[2, e.RowIndex].Value;
                int           contractId    = (int)dgvData[3, e.RowIndex].Value;
                UpdatePayment updatePayment = new UpdatePayment(id, sum, date, contractId);
                updatePayment.ShowDialog();
                break;

            case "dgv" + RentName:
                int        contrId      = (int)dgvData[1, e.RowIndex].Value;
                int        tradePointId = (int)dgvData[2, e.RowIndex].Value;
                DateTime   rentalStart  = (DateTime)dgvData[3, e.RowIndex].Value;
                DateTime   rentalEnd    = (DateTime)dgvData[4, e.RowIndex].Value;
                UpdateRent updateRent   = new UpdateRent(id, contrId, tradePointId, rentalStart, rentalEnd);
                updateRent.ShowDialog();
                break;

            case "dgv" + TradePointName:
                int              floor            = (int)dgvData[1, e.RowIndex].Value;
                bool             conditioning     = (bool)dgvData[2, e.RowIndex].Value;
                int              cost             = (int)dgvData[3, e.RowIndex].Value;
                UpdateTradePoint updateTradePoint = new UpdateTradePoint(id, floor, conditioning, cost);
                updateTradePoint.ShowDialog();
                break;
            }

            Refresh();
        }
        /// <summary>
        /// Maps Input parameters for Update Payments
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public UpdatePayment UpdateRequestMapper(UpdatePaymentRequest request)
        {
            UpdatePayment updatePayment = new UpdatePayment();
            int           formatMoney;

            if (request.Id.Contains("\""))
            {
                request.Id     = Regex.Replace(request.Id, "\"", "");
                request.Amount = Regex.Replace(request.Amount, "\"", "");
            }

            formatMoney = (int)(Convert.ToDecimal((request.Amount.Substring(1, request.Amount.Length - 1)).Replace(",", "").Trim()) * 100);

            updatePayment.Amount = formatMoney;
            updatePayment.Id     = request.Id;

            return(updatePayment);
        }
        public async Task <Unit> Handle(UpdatePayment request, CancellationToken cancellationToken)
        {
            var presence = _presences.GetAll()
                           .Include(o => o.Barbecue)
                           .FirstOrDefault(o => o.ParticipantId == request.ParticipantId && o.BarbecueId == request.BarbecueId);

            if (presence == null)
            {
                _notifications.AddNotification(AppConsts.PresenceNotFound);
                return(Unit.Value);
            }

            presence.Barbecue.UpdateDate = DateTime.Now;
            presence.Paid = request.Paid;
            await _presences.Commit();

            await _mediator.Publish(PaymentUpdated.Notify(request.BarbecueId, presence.Value, request.Paid));


            return(Unit.Value);
        }
        /// <summary>
        /// Update Payment Status
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public async Task <IEnumerable <Payment> > UpdatePayment(UpdatePayment request)
        {
            PaymentMapper mapPayment = new PaymentMapper();

            try
            {
                string readJsonString = File.ReadAllText("Payments/Data/payments.json");
                var    paymentList    = JsonSerializer.Deserialize <IEnumerable <Payment> >(readJsonString);

                GC.Collect();
                GC.WaitForPendingFinalizers();

                var paymentValues = mapPayment.MapPaymentsForUpdate(paymentList);

                foreach (var item in paymentValues.Where(data => data.Id == request.Id))
                {
                    item.Status = "Paid";
                }

                string jsonString = JsonSerializer.Serialize(paymentValues, new JsonSerializerOptions {
                    PropertyNamingPolicy = JsonNamingPolicy.CamelCase
                });
                File.WriteAllText("Payments/Data/payments.json", jsonString);

                return(await JsonSerializer
                       .DeserializeAsync <IEnumerable <Payment> >(File.OpenRead("Payments/Data/payments.json")));
            }
            catch (System.Exception ex)
            {
                throw ex;
            }
            finally
            {
                GC.Collect();
                GC.WaitForPendingFinalizers();
            }
        }
Esempio n. 7
0
 public async Task <ActionResult> UpdatePayment(Guid id, UpdatePayment command)
 {
     return(await SendAndHandleOperationCommand(command.Bind(cmd => cmd.Id, id)));
 }
Esempio n. 8
0
 public async Task <IActionResult> Put(int id, UpdatePayment data)
 {
     data.Data.Attributes.id = id;
     return(Ok(await _mediatr.Send(data)));
 }