Esempio n. 1
0
        public async Task <ActionResult> DocumentsEdit(EditAssignDocumentTemplateViewModel model)
        {
            if (ModelState.IsValid)
            {
                DocumentationBusinessTypeTemplate docuBusinessType = model.GetDocument();
                try
                {
                    await documentationBusinessTypeTemplateRepository.UpdateAsync(docuBusinessType);

                    return(RedirectToAction("AssignedDocuments", "BusinessTypeTemplates", new { id = model.BusinessTypeTemplateID }));
                }
                catch (Exception e)
                {
                    var errors = string.Join(",", e.Message);
                    ModelState.AddModelError(string.Empty, errors);
                }
            }

            return(View(model));
        }
Esempio n. 2
0
        public async Task <ActionResult> DocumentsCreate(EditAssignDocumentTemplateViewModel model)
        {
            if (ModelState.IsValid)
            {
                DocumentationBusinessTypeTemplate document = (DocumentationBusinessTypeTemplate)model.GetDocument();
                //document.BusinessTypeTemplateID = model.BusinessTypeTemplateID;

                try
                {
                    await documentationBusinessTypeTemplateRepository.CreateAsync(document);

                    return(RedirectToAction("AssignedDocuments", "BusinessTypeTemplates", new { id = model.BusinessTypeTemplateID }));
                }
                catch (Exception e)
                {
                    var errors = string.Join(",", e.Message);
                    ModelState.AddModelError(string.Empty, errors);
                }
            }

            ViewBag.DocumentationTemplateID = new SelectList(documentationTemplateRepository.UnAssignedDocumentationTemplates(model.BusinessTypeTemplateID), "DocumentationTemplateID", "DocumentationTemplateCode");
            // If we got this far, something failed, redisplay form
            return(View(model));
        }