Beispiel #1
0
        /// <summary>
        /// Handles saving a new <see cref="Payee"/>
        /// </summary>
        private static bool SaveEditPayee()
        {
            var address  = PayeeEdit.addressText.Text;
            var acc      = PayeeEdit.AccNumberText.Text;
            var name     = PayeeEdit.NameText.Text;
            var sortcode = PayeeEdit.SortCodeText.Text;

            if (string.IsNullOrEmpty(address) || string.IsNullOrEmpty(acc) || string.IsNullOrEmpty(name) ||
                string.IsNullOrEmpty(sortcode))
            {
                return(false);
            }

            var editedPayee = new Payee
            {
                Id        = EditPayee.Id,
                AccNumber = acc,
                Address   = address,
                Name      = name,
                SortCode  = sortcode
            };

            var selectedIndex = PayeeEdit.PayeeCombobox.SelectedIndex;

            DA.EditPayee(editedPayee, editedPayee.Id);
            ListAccessHelper.PayeeList[selectedIndex] = editedPayee;
            XmlDA.SaveXml();
            return(true);
        }
        public async Task <IActionResult> Edit(int id, [Bind("PayeeID,PayeeName,Address,City,State,PostCode,Phone")] Payee payee)
        {
            if (id != payee.PayeeID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(payee);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PayeeExists(payee.PayeeID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(payee));
        }
Beispiel #3
0
        /// <summary>
        /// Handles adding a new <see cref="Payee"/>
        /// </summary>
        private static bool AddPayee()
        {
            var payeeName = PayeeAdd.NameText.Text;
            var address   = PayeeAdd.addressText.Text;
            var sortCode  = PayeeAdd.SortCodeText.Text;
            var accNumber = PayeeAdd.AccNumberText.Text;

            if (string.IsNullOrEmpty(payeeName) || string.IsNullOrEmpty(sortCode) || string.IsNullOrEmpty(accNumber) || string.IsNullOrEmpty(address))
            {
                return(false);
            }

            var payee = new Payee
            {
                Id        = Guid.NewGuid(),
                Name      = payeeName,
                Address   = address,
                AccNumber = accNumber,
                SortCode  = sortCode
            };

            DA.InsertPayee(payee);
            ListAccessHelper.PayeeList.Add(payee);
            XmlDA.SaveXml();
            return(true);
        }
Beispiel #4
0
        public static List <Payee> GetPayee(int branchID)
        {
            var dbUtil = new DatabaseManager();
            var payees = new List <Payee>();

            using (var conn = new SqlConnection(dbUtil.getSQLConnectionString("MainDB")))
            {
                conn.Open();
                using (SqlCommand cmd = conn.CreateCommand())
                {
                    cmd.CommandType    = CommandType.StoredProcedure;
                    cmd.CommandText    = "spAccGLGetPayee";
                    cmd.CommandTimeout = 180;
                    cmd.Parameters.Clear();
                    cmd.Parameters.AddWithValue("@intIDMasLocation", branchID);

                    using (SqlDataReader reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            var payee = new Payee
                            {
                                PayeeID = ReferenceEquals(reader["intPayeeID"], DBNull.Value) ? 0 : Convert.ToInt32(reader["intPayeeID"]),
                                Name    = ReferenceEquals(reader["strName"], DBNull.Value) ? string.Empty : Convert.ToString(reader["strName"])
                            };

                            payees.Add(payee);
                        }

                        return(payees);
                    }
                }
            }
        }
        // GET: Payees/Edit/5
        public ActionResult Edit(int?id)
        {
            var CustomerQuery = from c in db.Users
                                where c.UserName == User.Identity.Name
                                select c;


            // Get the Customer
            AppUser customer = CustomerQuery.FirstOrDefault();

            if (customer.ActiveStatus == false)
            {
                return(View("Frozen"));
            }

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Payee payee = db.Payees.Find(id);

            if (payee == null)
            {
                return(HttpNotFound());
            }
            return(View(payee));
        }
Beispiel #6
0
        public ActionResult AddPayee(AppUser customer, Int32 PayeeID1)
        {
            var CustomerQuery = from c in db.Users
                                where c.UserName == User.Identity.Name
                                select c;

            AppUser user = CustomerQuery.FirstOrDefault();

            if (user == null)
            {
                return(HttpNotFound());
            }

            Payee selectedPayee = db.Payees.Find(PayeeID1);

            List <Payee> PayeeList = new List <Payee>();

            PayeeList.Add(selectedPayee);

            user.PayeeAccounts = new List <Payee>();

            user.PayeeAccounts.Add(selectedPayee);

            db.Entry(user).State = EntityState.Modified;
            db.SaveChanges();
            return(RedirectToAction("PayBillsPage", "Payees"));
        }
        public override IDeepCopyable CopyTo(IDeepCopyable other)
        {
            var dest = other as PaymentNotice;

            if (dest == null)
            {
                throw new ArgumentException("Can only copy to an object of the same type", "other");
            }

            base.CopyTo(dest);
            if (Identifier != null)
            {
                dest.Identifier = new List <Hl7.Fhir.Model.Identifier>(Identifier.DeepCopy());
            }
            if (StatusElement != null)
            {
                dest.StatusElement = (Code <Hl7.Fhir.Model.FinancialResourceStatusCodes>)StatusElement.DeepCopy();
            }
            if (Request != null)
            {
                dest.Request = (Hl7.Fhir.Model.ResourceReference)Request.DeepCopy();
            }
            if (Response != null)
            {
                dest.Response = (Hl7.Fhir.Model.ResourceReference)Response.DeepCopy();
            }
            if (CreatedElement != null)
            {
                dest.CreatedElement = (Hl7.Fhir.Model.FhirDateTime)CreatedElement.DeepCopy();
            }
            if (Provider != null)
            {
                dest.Provider = (Hl7.Fhir.Model.ResourceReference)Provider.DeepCopy();
            }
            if (Payment != null)
            {
                dest.Payment = (Hl7.Fhir.Model.ResourceReference)Payment.DeepCopy();
            }
            if (PaymentDateElement != null)
            {
                dest.PaymentDateElement = (Hl7.Fhir.Model.Date)PaymentDateElement.DeepCopy();
            }
            if (Payee != null)
            {
                dest.Payee = (Hl7.Fhir.Model.ResourceReference)Payee.DeepCopy();
            }
            if (Recipient != null)
            {
                dest.Recipient = (Hl7.Fhir.Model.ResourceReference)Recipient.DeepCopy();
            }
            if (Amount != null)
            {
                dest.Amount = (Hl7.Fhir.Model.Money)Amount.DeepCopy();
            }
            if (PaymentStatus != null)
            {
                dest.PaymentStatus = (Hl7.Fhir.Model.CodeableConcept)PaymentStatus.DeepCopy();
            }
            return(dest);
        }
Beispiel #8
0
        public static string ManagePayee(NameValueCollection querystring)
        {
            int integerParse;

            UserProfile userProfile = WebCommon.GetUserProfile();

            var payee = new Payee
            {
                PayeeID       = int.TryParse(querystring.Get("PayeeID"), out integerParse) ? integerParse : 0,
                CustomerID    = int.TryParse(querystring.Get("CustomerID"), out integerParse) ? integerParse : 0,
                BranchID      = int.TryParse(querystring.Get("BranchID"), out integerParse) ? integerParse : 0,
                PayeeName     = querystring.Get("PayeeName"),
                Firstname     = querystring.Get("FirstName"),
                Middlename    = querystring.Get("MiddleName"),
                Lastname      = querystring.Get("LastName"),
                Address       = querystring.Get("Address"),
                ContactPerson = querystring.Get("ContactPerson"),
                ContactNo     = querystring.Get("ContactNo"),
                TINNo         = querystring.Get("TINNo"),
                CompanyName   = querystring.Get("CompanyName"),
                CategoryID    = int.TryParse(querystring.Get("CategoryID"), out integerParse) ? integerParse : 0,
                StatusID      = int.TryParse(querystring.Get("StatusID"), out integerParse) ? integerParse : 0
                                //UserID = userProfile.UserId
            };

            string isInsert = querystring.Get("TransType");
            string param    = WebCommon.ToXML(payee);

            return(PayeeDAL.ManagePayee(param, isInsert));
        }
        private bool ValidateModel(Payee model)
        {
            var context = new ValidationContext(model, null, null);
            var results = new List <ValidationResult>();

            return(Validator.TryValidateObject(model, context, results, true));
        }
        public static List <Alias> CreateTestAliases(IQueryable <Payee> payees)
        {
            Payee        payeeWithAliases = payees.Where(p => p.Name == "Payee with Aliases").FirstOrDefault();
            List <Alias> aliases          = new List <Alias> {
                new Alias {
                    ID            = 1,
                    Name          = "WalMart 223235 WAL",
                    PayeeID       = payeeWithAliases.ID,
                    AliasForPayee = payeeWithAliases
                },
                new Alias {
                    ID            = 2,
                    Name          = "WalMart 37917",
                    PayeeID       = payeeWithAliases.ID,
                    AliasForPayee = payeeWithAliases
                },
                new Alias {
                    ID            = 3,
                    Name          = "Murphy USA",
                    PayeeID       = payeeWithAliases.ID,
                    AliasForPayee = payeeWithAliases
                }
            };

            return(aliases);
        }
Beispiel #11
0
        public Task<IList<Payee>> GetPayeesAsync()
        {
            if (this._cachedPayees == null || this._settings.CacheRegisteredDeviceData == false)
            {
                this._cachedPayees = new Lazy<Task<IList<Payee>>>(async () =>
                {
                    try
                    {
                        var budgetFile = await this.GetBudgetFileAsync();

                        var payees = budgetFile
                            .Value<JArray>("payees")
                            .Values<JObject>()
                            .Select(f => new Payee(f))
                            .ToHashSet(HashSetDuplicateOptions.Override);

                        var localChanges = await this.GetAllLocalChangesAsync("payee");

                        foreach (var localChange in localChanges)
                        {
                            var localPayee = new Payee(localChange);
                            payees.Add(localPayee, HashSetDuplicateOptions.Override);
                        }

                        return payees.ToList();
                    }
                    catch (Exception exception) when (exception is YnabApiException == false)
                    {
                        throw new YnabApiException("Error while loading the payees.", exception);
                    }
                });
            }

            return this._cachedPayees.Value;
        }
Beispiel #12
0
        public ActionResult CreatePayee([Bind(Include = "PayeeID, Name, Street, City, State, Zip, PhoneNumber, Type")] Payee Payee)
        {
            if (ModelState.IsValid)
            {
                // Ensure we get the right primary key
                var idObject = db.Payees.OrderByDescending(b => b.PayeeID).FirstOrDefault();
                if (idObject == null)
                {
                    Payee.PayeeID = "1";
                }
                else
                {
                    int    nextId       = Convert.ToInt32(idObject.PayeeID) + 1;
                    String nextIdString = nextId.ToString();
                    Payee.PayeeID = nextIdString;
                }


                // Adding the object to the DB
                db.Payees.Add(Payee);
                db.SaveChanges();

                // Redirect to the right page
                return(RedirectToAction("ApplicationSuccess"));
            }

            return(View());
        }
Beispiel #13
0
        /// <summary>
        /// The SaleRegistry Console Client Demonstrating the overall
        /// Workflow or Process of obtaining the ownership of the property.
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            try
            {
                string assetId = UniqueIdHelper.GenerateId();

                Payee          payee          = new Payee();
                Supervisor     supervisor     = new Supervisor(assetId);
                PropertyBuyer  propertyBuyer  = new PropertyBuyer();
                PropertySeller propertySeller = new PropertySeller();

                System.Console.WriteLine("Initiating the " +
                                         "Sale Deed Application Process");

                supervisor.InitApplication().Wait();
                supervisor.StartTheReviewProcess().Wait();
                supervisor.CompleteTheReviewProcess().Wait();

                propertyBuyer.PayTransferFee(payee.GetPayee(), assetId).Wait();
                supervisor.TransferOwnership(propertySeller.GetOwnerAddress(),
                                             propertyBuyer.GetBuyerAddress()).Wait();

                System.Console.WriteLine("Completed executing the " +
                                         "Sale Deed Application Process");
            }
            catch (Exception ex)
            {
                System.Console.WriteLine(ex.ToString());
            }

            System.Console.ReadLine();
        }
Beispiel #14
0
        public void Payee_CheckString()
        {
            var target = new Payee("Ryan", "Chen", "120000", "10%", new PayPeriod(3));
            var result = target.PaySlip;

            Assert.Equal("Ryan Chen,01 March to 31 March,10000,2669,7331,1000", result);
        }
Beispiel #15
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (Payee.Length != 0)
            {
                hash ^= Payee.GetHashCode();
            }
            if (Payer.Length != 0)
            {
                hash ^= Payer.GetHashCode();
            }
            if (Amount != 0)
            {
                hash ^= Amount.GetHashCode();
            }
            if (forProperty_ != null)
            {
                hash ^= ForProperty.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
        public PayeeResponse CreatePayee(Payee payee, ResponseType responseType = ResponseType.JSON)
        {
            StringBuilder requestUri = new StringBuilder($"{EndPoint}/create-payee?");

            AddRequestParameters(requestUri, RequestType.CreatePayee, payee);
            return(PostRequest <PayeeResponse>(requestUri, responseType));
        }
Beispiel #17
0
        public async Task <IActionResult> ScheduleBillPay(BillPayFormModel model)
        {
            Account account = await _acctRepo.GetAcctBpay(model.SenderAccountNumber);

            Payee payee = await _payeeRepo.Get(model.DestinationID);

            this.CheckAmountError(model.Amount);
            this.CanProceed(account, model.Amount);

            if (!ModelState.IsValid)
            {
                ViewBag.Payees = await _payeeRepo.GetAll();

                ViewBag.Accounts = await this.GetAccountsForViewBag();

                return(View(model));
            }

            if (account == null || payee == null)
            {
                return(NotFound());
            }

            string billpayJson = JsonConvert.SerializeObject(model);

            HttpContext.Session.SetString("BillpayJson", billpayJson);

            return(RedirectToAction(nameof(Confirm)));
        }
Beispiel #18
0
        internal async Task <AliasCrudVm> CreateViewModel(int?id, IAliasManagerService service)
        {
            if (id == null && GetRoutedAction() != nameof(Create))
            {
                return(null);
            }
            AliasCrudVm vm = null;

            if (id == null)
            {
                vm = new AliasCrudVm(null, service);
            }
            else
            {
                vm = new AliasCrudVm(await service.GetSingleAliasAsync(id, true), service);
            }
            if (GetRoutedAction() == nameof(Create) &&
                int.TryParse(GetRequestParameter("payeeID"), out int fetchedId))
            {
                Payee payee = await service.GetPayees().Extension().SingleOrDefaultAsync(p => p.ID == fetchedId);

                if (payee != null)
                {
                    vm.PayeeName = payee.Name;
                }
            }
            return(vm);
        }
Beispiel #19
0
    public static List <Payee> GetPayeeByName(string SearchQuery)
    {
        List <Payee> PayeeList = new List <Payee>();
        string       sql       = "SELECT * FROM Payees WHERE DefaultName LIKE @SearchQuery";

        using (SqlConnection con = new SqlConnection(GetConnectionString()))
        {
            using (SqlCommand cmd = new SqlCommand(sql, con))
            {
                cmd.Parameters.AddWithValue("SearchQuery", '%' + SearchQuery + '%');
                con.Open();
                SqlDataReader dr = cmd.ExecuteReader();
                Payee         payee;
                while (dr.Read())
                {
                    payee                         = new Payee();
                    payee.PayeeId                 = dr["PayeeId"].ToString();
                    payee.DefaultName             = dr["DefaultName"].ToString();
                    payee.DefaultStreetAddress    = dr["DefaultStreetAddress"].ToString();
                    payee.DefaultStreetAddressTwo = dr["DefaultStreetAddressTwo"].ToString();
                    payee.DefaultCity             = dr["DefaultCity"].ToString();
                    payee.DefaultRegion           = dr["DefaultRegion"].ToString();
                    payee.DefaultCountry          = dr["DefaultCountry"].ToString();
                    payee.DefaultPostalCode       = dr["DefaultPostalCode"].ToString();
                    PayeeList.Add(payee);
                }
                dr.Close();
            }
        }
        return(PayeeList);
    }
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         // Suitable nullity checks etc, of course :)
         if (Payer != null)
         {
             hashCode = hashCode * 59 + Payer.GetHashCode();
         }
         if (Payee != null)
         {
             hashCode = hashCode * 59 + Payee.GetHashCode();
         }
         if (ExtensionUType != null)
         {
             hashCode = hashCode * 59 + ExtensionUType.GetHashCode();
         }
         if (ExtendedDescription != null)
         {
             hashCode = hashCode * 59 + ExtendedDescription.GetHashCode();
         }
         if (ServiceId != null)
         {
             hashCode = hashCode * 59 + ServiceId.GetHashCode();
         }
         return(hashCode);
     }
 }
Beispiel #21
0
        public ObservableCollection <Payee> GetPayees()
        {
            ReadTheFile();
            XmlDocument doc = new XmlDocument();

            doc.Load(new StringReader(data));

            XmlNodeList  payeeNodes = doc.DocumentElement.SelectNodes("/KMYMONEY-FILE/PAYEES/PAYEE");
            List <Payee> payeeList  = new List <Payee>();

            PayeesObs = new ObservableCollection <Payee>();
            foreach (XmlNode payeeNode in payeeNodes)
            {
                Payee payee = new Payee();
                payee.Id              = payeeNode.Attributes["id"] == null ? "" : payeeNode.Attributes["id"].Value;
                payee.Name            = payeeNode.Attributes["name"] == null ? "" : payeeNode.Attributes["name"].Value;
                payee.Matchingenabled = payeeNode.Attributes["matchingenabled"] == null ? "" : payeeNode.Attributes["matchingenabled"].Value;
                payee.Email           = payeeNode.Attributes["email"] == null ? "" : payeeNode.Attributes["email"].Value;
                payee.Reference       = payeeNode.Attributes["reference"] == null ? "" : payeeNode.Attributes["reference"].Value;
                payee.Notes           = payeeNode.Attributes["notes"] == null ? "" : payeeNode.Attributes["notes"].Value;
                payee.AddressInfo     = GetAddress(payeeNode);
                PayeesObs.Add(payee);
            }
            return(PayeesObs);
        }
        private void DgEntries_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            if (dgEntries[e.ColumnIndex, e.RowIndex] is DataGridViewComboBoxCell)
            {
                DataGridViewComboBoxCell dcc = (DataGridViewComboBoxCell)dgEntries[e.ColumnIndex, e.RowIndex];
                if (dcc != null && dcc.Value != null)
                {
                    foreach (var item in dcc.Items)
                    {
                        if (item is Category)
                        {
                            Category cat = item as Category;
                            if (dcc.Value.ToString() == cat.Name)
                            {
                                dcc.Tag = cat;
                                break;
                            }
                        }

                        if (item is Payee)
                        {
                            Payee pay = item as Payee;
                            if (dcc.Value.ToString() == pay.Name)
                            {
                                dcc.Tag = pay;
                                break;
                            }
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Handles updating a <see cref="Payee"/> record in the database
        /// </summary>
        /// <param name="payee">The updated <see cref="Payee"/></param>
        /// <param name="id">The id of the <see cref="Payee"/> to update</param>
        public async void EditPayee(Payee payee, Guid id)
        {
            try
            {
                using (Conn)
                    using (var comm = Conn.CreateCommand())
                    {
                        await Conn.OpenAsync();

                        comm.CommandText = "UPDATE payee " +
                                           "SET Id = @NewId, Name = @Name, SortCode = @SortCode, " +
                                           "AccountNumber = @AccountNumber, Address = @Address " +
                                           "WHERE Id = @Id;";

                        comm.Parameters.AddWithValue("@NewId", payee.Id.ToString());
                        comm.Parameters.AddWithValue("@Name", payee.Name);
                        comm.Parameters.AddWithValue("@SortCode", payee.SortCode);
                        comm.Parameters.AddWithValue("@AccountNumber", payee.AccNumber);
                        comm.Parameters.AddWithValue("@Address", payee.Address);
                        comm.Parameters.AddWithValue("@Id", id.ToString());

                        await comm.ExecuteNonQueryAsync();

                        await Conn.CloseAsync();
                    }
            }
            catch (Exception ex)
            {
                ErrorHelper.SendError(ex);
            }
        }
        /// <summary>
        /// Handles inserting a new <see cref="Payee"/> into the database
        /// </summary>
        /// <param name="payee">The <see cref="Payee"/> to be inserted</param>
        public async void InsertPayee(Payee payee)
        {
            try
            {
                using (Conn)
                    using (var comm = Conn.CreateCommand())
                    {
                        await Conn.OpenAsync();

                        comm.CommandText = "INSERT INTO " +
                                           "payee(Id, Name, SortCode, AccountNumber, Address) " +
                                           "VALUES (@Id, @Name, @SortCode, @AccountNumber, @Address)";

                        comm.Parameters.AddWithValue("@Id", payee.Id.ToString());
                        comm.Parameters.AddWithValue("@Name", payee.Name);
                        comm.Parameters.AddWithValue("@SortCode", payee.SortCode);
                        comm.Parameters.AddWithValue("@AccountNumber", payee.AccNumber);
                        comm.Parameters.AddWithValue("@Address", payee.Address);

                        await comm.ExecuteNonQueryAsync();

                        await Conn.CloseAsync();
                    }
            }
            catch (Exception ex)
            {
                ErrorHelper.SendError(ex);
            }
        }
Beispiel #25
0
    public static int UpdatePayee(Payee original_payee,
                                  Payee payee)
    {
        int    updateCount = 0;
        string sql         = "UPDATE Payees SET "
                             + "DefaultName = @DefaultName, "
                             + "DefaultStreetAddress = @DefaultStreetAddress, "
                             + "DefaultStreetAddressTwo = @DefaultStreetAddressTwo "
                             + "DefaultCity = @DefaultCity "
                             + "DefaultRegion = @DefaultRegion "
                             + "DefaultCountry = @DefaultCountry "
                             + "DefaultPostalCode = @DefaultPostalCode "
                             + "WHERE PayeeId = @original_PayeeId ";

        using (SqlConnection con = new SqlConnection(GetConnectionString()))
        {
            using (SqlCommand cmd = new SqlCommand(sql, con))
            {
                cmd.Parameters.AddWithValue("DefaultName", payee.DefaultName);
                cmd.Parameters.AddWithValue("DefaultStreetAddress", payee.DefaultStreetAddress);
                cmd.Parameters.AddWithValue("DefaultStreetAddressTwo", payee.DefaultStreetAddressTwo);
                cmd.Parameters.AddWithValue("DefaultCity", payee.DefaultCity);
                cmd.Parameters.AddWithValue("DefaultRegion", payee.DefaultRegion);
                cmd.Parameters.AddWithValue("DefaultCountry", payee.DefaultCountry);
                cmd.Parameters.AddWithValue("DefaultPostalCode", payee.DefaultPostalCode);
                cmd.Parameters.AddWithValue("original_PayeeId", original_payee.PayeeId);
                con.Open();
                updateCount = cmd.ExecuteNonQuery();
            }
        }
        return(updateCount);
    }
Beispiel #26
0
        public long AddPayee(Guid userId, Payee payee)
        {
            FilterDefinition <User>         filter = Builders <User> .Filter.Empty;
            List <FilterDefinition <User> > ops    = new List <FilterDefinition <User> >(10);

            if (!userId.Equals(Guid.Empty))
            {
                ops.Add(Builders <User> .Filter.Eq(x => x.Id, userId));
            }

            if (ops.Count > 0)
            {
                filter = Builders <User> .Filter.And(ops);
            }

            Task <UpdateResult> res = null;


            var data = Builders <User> .Update
                       .Push(f => f.Payees, payee);

            res = _Collection.UpdateOneAsync(filter, data);

            return(res != null ? res.Result.ModifiedCount : 0);
        }
Beispiel #27
0
    public static List <Payee> GetAllPayees()
    {
        List <Payee> PayeeList = new List <Payee>();
        string       sql       = "SELECT * FROM Payees";

        using (SqlConnection con = new SqlConnection(GetConnectionString()))
        {
            using (SqlCommand cmd = new SqlCommand(sql, con))
            {
                con.Open();
                SqlDataReader dr = cmd.ExecuteReader();
                Payee         payee;
                while (dr.Read())
                {
                    payee                         = new Payee();
                    payee.PayeeId                 = dr["PayeeId"].ToString();
                    payee.DefaultName             = dr["DefaultName"].ToString();
                    payee.DefaultStreetAddress    = dr["DefaultStreetAddress"].ToString();
                    payee.DefaultStreetAddressTwo = dr["DefaultStreetAddressTwo"].ToString();
                    payee.DefaultCity             = dr["DefaultCity"].ToString();
                    payee.DefaultRegion           = dr["DefaultRegion"].ToString();
                    payee.DefaultCountry          = dr["DefaultCountry"].ToString();
                    payee.DefaultPostalCode       = dr["DefaultPostalCode"].ToString();
                    PayeeList.Add(payee);
                }
                dr.Close();
            }
        }
        return(PayeeList);
    }
        public ActionResult <Expense> Post([FromBody] RegisterExpense expense)
        {
            if (ModelState.IsValid)
            {
                #region Validate Payee
                var roommate = _roommates.GetById(expense.PayeeId);
                if (roommate == null)
                {
                    ModelState.AddModelError("PayeeId", "The specified PayeeId is not valid or does not represent a registered Roommate.");
                    return(null);
                }
                var payee = new Payee {
                    Id = roommate.Id, Name = roommate.Name
                };
                #endregion

                var result = _registerExpense(this, expense, payee);
                if (result != null)
                {
                    return(result);
                }
            }

            return(BadRequest(ModelState));
        }
Beispiel #29
0
    public static Payee GetPayeeById(string PayeeId)
    {
        Payee  payee;
        string sql = "SELECT * FROM Payees WHERE PayeeId = @PayeeId";

        using (SqlConnection con = new SqlConnection(GetConnectionString()))
        {
            using (SqlCommand cmd = new SqlCommand(sql, con))
            {
                cmd.Parameters.AddWithValue("PayeeId", PayeeId);
                con.Open();
                SqlDataReader dr = cmd.ExecuteReader();
                dr.Read();

                payee                         = new Payee();
                payee.PayeeId                 = dr["PayeeId"].ToString();
                payee.DefaultName             = dr["DefaultName"].ToString();
                payee.DefaultStreetAddress    = dr["DefaultStreetAddress"].ToString();
                payee.DefaultStreetAddressTwo = dr["DefaultStreetAddressTwo"].ToString();
                payee.DefaultCity             = dr["DefaultCity"].ToString();
                payee.DefaultRegion           = dr["DefaultRegion"].ToString();
                payee.DefaultCountry          = dr["DefaultCountry"].ToString();
                payee.DefaultPostalCode       = dr["DefaultPostalCode"].ToString();
                dr.Close();
            }
        }
        return(payee);
    }
        public Payee AddPayee(Guid userId, Payee payee)
        {
            Payee res    = null;
            var   detail = _UserCollection.GetById(userId);

            if (detail != null)
            {
                var linkingBank = _LinkingBankCollection.GetById(payee.LinkingBankId);

                if (linkingBank != null)
                {
                    // get payee detail
                    var payeeDetail = _UserCollection.GetByAccountNumber(payee.AccountNumber);


                    if (payeeDetail != null)
                    {
                        if (string.IsNullOrEmpty(payee.MnemonicName))
                        {
                            payee.MnemonicName = payeeDetail.Name;
                        }
                        payee.Id = Guid.NewGuid();
                        var countModified = _UserCollection.AddPayee(userId, payee);
                        if (countModified > 0)
                        {
                            res = payee;
                        }
                    }
                }
            }

            return(res);
        }
        public PayeeResponse GetPayeeStatus(Payee payee, ResponseType responseType = ResponseType.JSON)
        {
            StringBuilder requestUri = new StringBuilder($"{EndPoint}/get-payee-status?");

            AddRequestParameters(requestUri, RequestType.GetPayeeStatus, payee);
            return(Request <PayeeResponse>(requestUri, responseType));
        }
Beispiel #32
0
        public ActionResult Create(Payee payee)
        {
            if (ModelState.IsValid)
            {
                db.Payees.Add(payee);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(payee);
        }
Beispiel #33
0
        //[ClassInitialize]
        public void CreateSampleBudget()
        {
            using (var budget = new BudgetContext())
            {
                budget.Database.Migrate();

                var checking = new Account(AccountType.Checking, "Test Checking Account");
                budget.Accounts.Add(checking);
                var savings = new Account(AccountType.Savings, "Test Savings Account");
                budget.Accounts.Add(savings);
                var creditCard = new Account(AccountType.CreditCard, "Test Credit Card");
                budget.Accounts.Add(creditCard);

                var housing = new Category(null, "Housing", null);
                budget.Categories.Add(housing);

                var mortgage = new Category(housing, "Mortgage", null);
                budget.Categories.Add(mortgage);
                var propertyTax = new Category(housing, "Property Tax", null);
                budget.Categories.Add(propertyTax);
                var insurance = new Category(housing, "Insurance", null);
                budget.Categories.Add(insurance);

                var transportation = new Category(null, "Transportation", null);
                budget.Categories.Add(transportation);
                var everydayExpenses = new Category(null, "Everyday Expenses", null);
                budget.Categories.Add(everydayExpenses);
                var savingsGoals = new Category(null, "Savings Goals", null);
                budget.Categories.Add(savingsGoals);

                var chaseBank = new Payee("Chase Bank");
                budget.Payees.Add(chaseBank);
                budget.Payees.Add(new Payee("Citibank"));
                budget.Payees.Add(new Payee("Bank of America"));
                budget.Payees.Add(new Payee("Shell"));
                budget.Payees.AddRange(new Payee[] {
                    new Payee("Texaco"),
                    new Payee("Chevrolet"),
                    new Payee("PEMCO Insurance"),
                    new Payee("Safeway"),
                    new Payee("Target"),
                    new Payee("New York Times"),
                    new Payee("Microsoft Corporation")
                    });

                budget.SaveChanges();
            }
        }
        protected static void Read(XmlReader reader, Payee aPayee)
        {
            string lastName = String.Empty;
            while (reader.Read())
            {
                if (reader.NodeType == XmlNodeType.Element)
                {
                    lastName = reader.Name;
                }
                if (reader.NodeType == XmlNodeType.Text)
                {
                    if (lastName == "NAME")
                    {                       
                        aPayee.NAME = reader.Value.Trim();
                    }
                    if (lastName == "ADDR1")
                    {
                        aPayee.ADDR1 = reader.Value.Trim();
                    }
                    if (lastName == "ADDR2")
                    {
                        aPayee.ADDR2= reader.Value.Trim();
                    }
                    if (lastName == "ADDR3")
                    {
                        aPayee.ADDR2= reader.Value.Trim();
                    }

                    if (lastName == "CITY")
                    {
                        aPayee.NAME = reader.Value.Trim();
                    }
                    if (lastName == "POSTALCODE")
                    {
                        aPayee.POSTALCODE = reader.Value.Trim();
                    }
                    if (lastName == "COUNTRY")
                    {
                        aPayee.COUNTRY = reader.Value.Trim();
                    }
                    if (lastName == "PHONE")
                    {
                        aPayee.COUNTRY = reader.Value.Trim();
                    }
                }
                if (reader.NodeType == XmlNodeType.EndElement && reader.Name == "PAYEE")
                {
                    return;
                }
            }
        }
Beispiel #35
0
 public ActionResult Edit(Payee payee)
 {
     if (ModelState.IsValid)
     {
         db.Entry(payee).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(payee);
 }