Example #1
0
        public ActionResult Edit(int customerId, int licenseId)
        {
            var license = service.GetById(licenseId);

            if (license == null || license.Customer.Id != customerId)
            {
                return(HttpNotFound());
            }
            else
            {
                var vm = converter.EntityToViewmodel(license);
                return(View(vm));
            }
        }
Example #2
0
        /// <summary>
        ///     Requests the entity identified by the id parameter from the underlying service.
        ///     If lookup is successful, an edit form for the entity's corresponding viewmodel is returned.
        /// </summary>
        /// <param name="id"></param>
        /// <returns>
        ///     ViewResult when the requested entity can by found by the underlying service.
        ///     HttpStatusCodeResult (HTTP 400) when the entity id is not provided.
        ///     HttpNotFoundResult (HTTP 404) when the entity id was provided but not found in the underlying service.
        /// </returns>
        public virtual ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            var entity = service.GetById(id.Value);

            if (entity == null)
            {
                return(HttpNotFound());
            }
            else
            {
                var vm = converter.EntityToViewmodel(entity);
                return(View(vm));
            }
        }
Example #3
0
        public ActionResult Create(int customerId)
        {
            var customer = customerService.GetById(customerId);

            var vm = new LicenseViewModel
            {
                CustomerId   = customerId,
                CustomerName = customer.Name
            };

            return(View(vm));
        }