Пример #1
0
        public ActionResult Create(CreateCaseViewModel vm)
        {
            userID = User.Identity.GetUserId();

            if (db.Cases.Any(x => x.Aa == vm.Aa && x.UserId == userID) || !ModelState.IsValid)
            {
                vm.PrepareLists(userID);
                return(View(vm));
            }

            if (vm.newAttorney)
            {
                vm.AttorneyId = AttorneyRepository.InsertAttorney(userID, vm);
            }

            if (vm.newCourt)
            {
                vm.CourtId = CourtRepository.InsertCourt(userID, vm);
            }

            if (vm.newProsecution)
            {
                vm.ProsecutionId = PartyRepository.InsertPartyProsecution(userID, vm);
            }

            if (vm.newDefense)
            {
                vm.DefenseId = PartyRepository.InsertPartyDefense(userID, vm);
            }

            if (vm.newRecipient)
            {
                vm.RecipientId = PartyRepository.InsertPartyRecipient(userID, vm);
            }

            CaseRepository.InsertCaseFromViewModel(userID, vm);

            return(RedirectToAction("Index"));
        }