コード例 #1
0
		public ActionResult Create (TaxpayerRecipient item)
		{
			if (!string.IsNullOrEmpty (item.Id)) {
				var entity = TaxpayerRecipient.TryFind (item.Id);

				if (entity != null) {
					ModelState.AddModelError ("", Resources.TaxpayerRecipientAlreadyExists);
				}
			}

			if (!ModelState.IsValid) {
				return PartialView ("_Create", item);
			}

			item.Id = item.Id.ToUpper ().Trim ();
			item.Name = item.Name?.Trim ();
			item.Email = item.Email.Trim ();

			if (string.IsNullOrWhiteSpace (item.Name)) {
				item.Name = null;
			}

			using (var scope = new TransactionScope ()) {
				item.CreateAndFlush ();
			}

			return PartialView ("_CreateSuccesful", item);
		}
コード例 #2
0
ファイル: CustomersController.cs プロジェクト: mictlanix/mbe
        public ActionResult AddTaxpayer(int id, string value)
        {
            var item     = Customer.TryFind(id);
            var taxpayer = TaxpayerRecipient.TryFind(value);

            if (item == null)
            {
                Response.StatusCode = 400;
                return(Content(Resources.CustomerNotFound));
            }

            if (taxpayer == null)
            {
                Response.StatusCode = 400;
                return(Content(Resources.TaxpayerRecipientNotFound));
            }

            using (var scope = new TransactionScope()) {
                item.Taxpayers.Add(taxpayer);
                item.Update();
            }

            return(Json(new { id = id, result = true }));
        }