Beispiel #1
0
 public void PaymentListView_InsertItem(Payment payment)
 {
     if (ModelState.IsValid)
     {
         try
         {
             Service.UpdatePayment(payment);
             //Session["Success"] = true;
             //Response.RedirectToRoute("Default");
         }
         catch (Exception)
         {
             ModelState.AddModelError(String.Empty, "Ett oväntat fel inträffade då betalningssätt uppgiften skulle läggas till.");
         }
     }
 }
Beispiel #2
0
        /// <summary>
        /// Updates payment
        /// </summary>
        /// <param name="payment"></param>
        public void UpdatePayment(Payment payment)
        {
            using (SqlConnection conn = CreateConnection())
            {
                try
                {
                    SqlCommand cmd = new SqlCommand("appSchema.uspUpdatePayment", conn);
                    cmd.CommandType = CommandType.StoredProcedure;

                    conn.Open();
                    cmd.Parameters.Add("@PaymentID", SqlDbType.Int, 4).Value = payment.PaymentID;
                    cmd.Parameters.Add("@PaymentType", SqlDbType.NVarChar, 30).Value = payment.PaymentType;
                    cmd.ExecuteNonQuery();

                }
                catch
                {
                    throw new ApplicationException("An error occured in the data access layer.");
                }
            }
        }
Beispiel #3
0
        public void UpdatePayment(Payment payment)
        {

            ICollection<ValidationResult> validationResults;
            if (!payment.Validate(out validationResults))
            {
                var ex = new ValidationException("Objektet klarade inte valideringen.");
                ex.Data.Add("ValidationResults", validationResults);
                throw ex;
            }
            if (payment.PaymentID == 0) // New post if ID is 0!
            {
                PaymentDAL.InsertPayment(payment);
            }
            else
            {
                PaymentDAL.UpdatePayment(payment);
            }

        }