예제 #1
0
        public static void SavePaymentStaging(String username, List <Data_PaymentStaging> payments)
        {
            try
            {
                using (NewcourtEntities ctx = new NewcourtEntities())
                {
                    List <PaymentStaging> records = ctx.PaymentStaging.Where(a => a.Username == username).ToList();

                    foreach (var i in payments)
                    {
                        PaymentStaging current = records.FirstOrDefault(a => a.Username == i.Username && a.SupplierId == i.SuppplierId);

                        if (current != null)
                        {
                            current.Amount = i.Amount;
                        }
                        else
                        {
                            ctx.PaymentStaging.Add(new PaymentStaging()
                            {
                                Username   = i.Username,
                                SupplierId = i.SuppplierId,
                                Amount     = i.Amount
                            });
                        }
                    }

                    ctx.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #2
0
        public static void SavePaymentStaging(Data_PaymentStaging payment)
        {
            try
            {
                using (NewcourtEntities ctx = new NewcourtEntities())
                {
                    PaymentStaging record = ctx.PaymentStaging.FirstOrDefault(a => a.Username == payment.Username && a.SupplierId == payment.SuppplierId);

                    if (record != null)
                    {
                        record.Amount = payment.Amount;
                        ctx.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #3
0
        public static void DeleteFromPaymentStaging(String username, int supplierId)
        {
            try
            {
                using (NewcourtEntities ctx = new NewcourtEntities())
                {
                    PaymentStaging payment = ctx.PaymentStaging.FirstOrDefault(a => a.Username == username && a.SupplierId == supplierId);

                    if (payment != null)
                    {
                        ctx.PaymentStaging.Remove(payment);
                        ctx.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }