예제 #1
0
        public ActionResult Create(CompanyAdvice companyAdvice, FormCollection form)
        {
            if (companyAdvice.CompanysId == null)
            {
                ModelState.AddModelError("CompanysId", "Please choose a company.");
            }
            ValidateAdvice(companyAdvice);

            if (ModelState.IsValid)
            {
                try
                {
                    _adviceApplicationService.AddCompanyAdvice(CurrentMentor, companyAdvice);

                    return RedirectToAction("Index", "Advice");
                }
                catch
                {
                    return RedirectToAction("Create");
                }
            }

            var companies = _companyApplicationService.GetAllCompanies();
            ViewData["Companies"] = new SelectList(companies, "Id", "CompanyName", companyAdvice.CompanysId);
            ViewData["Semaphores"] = _semaphoreApplicationService.GetAllSemaphores();
            SetAdviceTagViewData();
            return View(companyAdvice);
        }
예제 #2
0
 public ActionResult Edit(CompanyAdvice companyAdvice, FormCollection form)
 {
     ValidateAdvice(companyAdvice);
     if (ModelState.IsValid)
     {
         _adviceApplicationService.UpdateAdvice(companyAdvice);
         return RedirectToAction("Index", "Advice");   
     }
     SetAdviceTagViewData();
     ViewData["Semaphores"] = _semaphoreApplicationService.GetAllSemaphores();
     var advice = _adviceApplicationService.GetAdvice(companyAdvice.Id.Value) as CompanyAdvice;
     var company = _companyApplicationService.GetCompany(advice.CompanysId.Value);
     ViewData["Company"] = company;
     return View(advice);
 }