Esempio n. 1
0
        public async Task <bool> InsertTransactionAsync(SponsorTransactionError error)
        {
            DataTable dt = new DataTable();

            dt.Columns.Add("SponsorName");
            dt.Columns.Add("Phone");
            dt.Columns.Add("Date");
            dt.Columns.Add("Time");
            dt.Columns.Add("ReceiptNumber");
            dt.Columns.Add("CardNumber");
            dt.Columns.Add("TrackingNumber");
            dt.Columns.Add("Amount");
            DataRow row = dt.NewRow();

            row["SponsorName"]    = error.SponsorName;
            row["Phone"]          = error.Phone;
            row["Date"]           = error.Date;
            row["Time"]           = error.Time;
            row["ReceiptNumber"]  = error.ReceiptNumber;
            row["CardNumber"]     = error.CardNumber;
            row["TrackingNumber"] = error.TrackingNumber;
            row["Amount"]         = error.Amount;

            try
            {
                await new ColleagueRepository(db).DeleteErrorAsync(error.ErrorID);
            }
            catch (Exception)
            { }

            return(await InsertTransactionAsync(row, error.ColleagueID));
        }
        public async Task <bool> DeleteErrorAsync(SponsorTransactionError error)
        {
            if (!(await IsExistErrorAsync(error)))
            {
                throw new NotFoundException();
            }

            try
            {
                db.Errors.Remove(error);
                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
        public async Task <bool> InsertErrorAsync(SponsorTransactionError error)
        {
            if (await IsExistErrorAsync(error))
            {
                throw new DuplicatePhoneNumberException();
            }

            try
            {
                await db.Errors.AddAsync(error);

                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
        public async Task <bool> InsertErrorAsync(SponsorTransaction st, ErrorMessage Message)
        {
            var err = new SponsorTransactionError();

            err.SponsorName    = st.MySponsor?.Name.ToString() ?? "";
            err.Phone          = st.MySponsor?.PhoneNumber.ToString() ?? "";
            err.Date           = st.MyTransaction?.TransactionDate.Date.ToString() ?? st.MyReceipt?.TransactionDate.Date.ToString() ?? "";
            err.Time           = st.MyTransaction?.TransactionDate.TimeOfDay.ToString() ?? st.MyReceipt?.TransactionDate.TimeOfDay.ToString() ?? "";
            err.ReceiptNumber  = st.MyReceipt?.ReceiptNumber.ToString() ?? "";
            err.CardNumber     = st.MyTransaction?.LastFourNumbersOfBankCard.ToString() ?? "";
            err.TrackingNumber = st.MyTransaction?.TrackingNumber.ToString() ?? "";
            err.Amount         = st.MyTransaction?.Amount.ToString() ?? st.MyReceipt?.Amount.ToString() ?? "";
            err.ErrorMessage   = Message.ToString().Replace('_', ' ');
            err.ColleagueID    = st.ColleagueID;

            await InsertErrorAsync(err);

            return(true);
        }
        public async Task <bool> InsertErrorAsync(DataRow row, ErrorMessage Message, int ColleagueID)
        {
            var err = new SponsorTransactionError();

            err.SponsorName    = row["SponsorName"].ToString();
            err.Phone          = row["Phone"].ToString();
            err.Date           = row["Date"].ToString();
            err.Time           = row["Time"].ToString();
            err.ReceiptNumber  = row["ReceiptNumber"].ToString();
            err.CardNumber     = row["CardNumber"].ToString();
            err.TrackingNumber = row["TrackingNumber"].ToString();
            err.Amount         = row["Amount"].ToString();
            err.ErrorMessage   = Message.ToString().Replace('_', ' ');
            err.ColleagueID    = ColleagueID;

            await InsertErrorAsync(err);

            return(true);
        }
 public async Task <bool> IsExistErrorAsync(SponsorTransactionError error)
 {
     return(await IsExistErrorAsync(error.ErrorID));
 }