コード例 #1
0
        public ActionResult Edit(PaymentMethod paymentMethod)
        {
            try
            {
                var files = Utilities.SaveFiles(Request.Files, Utilities.GetNormalFileName(paymentMethod.Title), StaticPaths.PaymentMethods);

                if (files.Count > 0)
                {
                    paymentMethod.Filename = files[0].Title;
                }

                paymentMethod.LastUpdate = DateTime.Now;

                ViewBag.Success = true;

                if (paymentMethod.ID == -1)
                {
                    PaymentMethods.Insert(paymentMethod);

                    UserNotifications.Send(UserID, String.Format("جدید - روش پرداخت '{0}'", paymentMethod.Title), "/Admin/PaymentMethod/Edit/" + paymentMethod.ID, NotificationType.Success);
                    paymentMethod = new PaymentMethod();
                }
                else
                {
                    PaymentMethods.Update(paymentMethod);
                }
            }
            catch (Exception ex)
            {
                SetErrors(ex);
            }

            return(ClearView(paymentMethod));
        }