Example #1
0
        public ActionResult CreateList(ListViewModel list, AccountViewModel account)
        {
            try
            {
                Mapper.Initialize(cfg => cfg.CreateMap <ListViewModel, ListDTO>());
                var listDTO = Mapper.Map <ListViewModel, ListDTO>(list);

                Mapper.Initialize(cfg => cfg.CreateMap <AccountViewModel, AccountDTO>());
                var accountDTO = Mapper.Map <AccountViewModel, AccountDTO>(account);

                listService.CreateListByAccount(listDTO, accountDTO);

                return(Json("Список контактов создан", JsonRequestBehavior.AllowGet));
            }
            catch (ValidationException ex)
            {
                return(Json("Exception: " + ex.Message + "\nPropery: " + ex.Property, JsonRequestBehavior.AllowGet));
            }
        }