public int CreateCampaign(Campaign camp) { var output = 0; Utilities.Try(() => { Guard.NotNull(camp, nameof(camp)); using (var transaction = new TransactionScope()) { var intCamp = _campaignRepo.CreateCampaign(camp); if (intCamp == 0) { throw new Exception("Unable to Create Campaign.,"); } if (camp.CampaignDetails != null) { if (camp.CampaignDetails.Count > 0) { foreach (var c in camp.CampaignDetails) { c.CampaignId = intCamp; _campaignDetailsRepo.CreateCampaignDetails(c); } } } if (camp.Goals != null) { if (camp.Goals.Count > 0) { foreach (var g in camp.Goals) { g.CampaignId = intCamp; _goalRepo.CreateGoal(g); } } } output = intCamp; if (output != 0) { transaction.Complete(); } transaction.Dispose(); } }, "CreateCampaign(Campaign camp)", log); return(output); }
public IActionResult Add(Goal goal) { if (ModelState.IsValid) { _repos.CreateGoal(goal); return(RedirectToAction("Details", new { goalId = goal.GoalId })); } return(View(goal)); } // Add method ends
public Goal CreateGoal(Guid UserId, Goal goal) { return(_goalRepository.CreateGoal(UserId, goal)); }