Exemplo n.º 1
0
		public JsonResult Add(AddRiskForm form)
		{
			var customer = _context.Customers.Include(x => x.Risks).Single(x => x.Id == form.CustomerId);

			var risk = Mapper.Map<Risk>(form);

			customer.Risks.Add(risk);

			_context.SaveChanges();

			var model = Mapper.Map<CustomerRiskViewModel>(risk);

			return BetterJson(model);
		}
Exemplo n.º 2
0
        public JsonResult Add(AddRiskForm form)
        {
            var customer = _context.Customers.Include(x => x.Risks).Single(x => x.Id == form.CustomerId);

            var risk = Mapper.Map <Risk>(form);

            customer.Risks.Add(risk);

            _context.SaveChanges();

            var model = Mapper.Map <CustomerRiskViewModel>(risk);

            return(BetterJson(model));
        }