コード例 #1
0
        public ActionResult Cancel(string id)
        {
            if (string.IsNullOrEmpty(id))
            {
                throw new InvalidOperationException("The value of id can not be null or empty.");
            }

            Guid shipmentId;

            try
            {
                shipmentId = new Guid(id);
            }
            catch (FormatException)
            {
                throw new InvalidOperationException("The value of id is incorrect.");
            }

            var repository = new ShipmentRepository();

            repository.DeleteShipment(shipmentId);

            return(this.RedirectToAction("Index"));
        }