public ActionResult Create(long id)
 {
     var loanApplication = _controleHelper.FirstOrDefault<LoanApplication>(l => l.Id == id, null, l => l.Loan);
     var CommitteeResolution = new CommitteeResolutionViewModel();
     CommitteeResolution.LoanApplicationId = id;
     return View(CommitteeResolution);
 }
        public ActionResult Create(CommitteeResolutionViewModel model)
        {
            try
            {
                var file = model.attachment;
                if (file.ContentLength > 0)
                {
                    var fileName = Path.GetFileName(file.FileName);
                    var guid = Guid.NewGuid();
                    var path = AppDomain.CurrentDomain.BaseDirectory + "/App_Data/Uploads/" + guid.ToString() + Path.GetExtension(file.FileName);
                    file.SaveAs(path);

                    using (var unitOfWork = new UnitOfWork(new BankModuleFactory()))
                    {
                        var DocumentService = new DocumentService(unitOfWork);
                        var document = new Document()
                        {
                            DocumentType = BusinessEntities.DocumentTypes.Other,
                            Link = "Uploads/" + guid.ToString() + Path.GetExtension(file.FileName),
                        };
                        model.ProtocolDocument = DocumentService.Add(document);
                        unitOfWork.Commit();
                        model.ProtocolDocumentId = model.ProtocolDocument.Id;
                    }
                }

                if (!ModelState.IsValid)
                {
                    return View(model);
                }

                var result = _controleHelper.CreateEntity<CommitteeResolution, CommitteeResolutionViewModel>(model);
                if (result.Error.Any())
                {
                    ModelState.AddModelError(string.Empty, result.Error.First().ErrorMessage);
                    return View(model);
                }
                return RedirectToAction("Details", new { id = result.Entity.LoanApplicationId });
            }
            catch (Exception ex)
            {
                ModelState.AddModelError(string.Empty, ex.Message);
                return View(model);
            }
        }
 public ActionResult Edit(long id, CommitteeResolutionViewModel model)
 {
     try
     {
         if (!ModelState.IsValid)
         {
             return View(model);
         }
         var result = _controleHelper.UpdateEntity<CommitteeResolution, CommitteeResolutionViewModel>(model, application => application.Id == id);
         if (result.Error.Any())
         {
             ModelState.AddModelError(string.Empty, result.Error.First().ErrorMessage);
             return View(model);
         }
         return RedirectToAction("Details", new { id = result.Entity.LoanApplicationId });
     }
     catch (Exception ex)
     {
         ModelState.AddModelError(string.Empty, ex.Message);
         return View(model);
     }
 }