Esempio n. 1
0
        public async Task <ActionResult> Add(Document model, string submit)
        {
            if (model != null)
            {
                if (submit == "Thêm")
                {
                    isAddNew = true;
                    var document = new Document
                    {
                        Title        = model.Title,
                        Description  = model.Description,
                        CreatedDate  = DateTimeHelper.GetCurrentDateTime(),
                        ModifiedDate = DateTimeHelper.GetCurrentDateTime(),
                        FilePath     = model.FilePath
                    };
                    await _documentService.AddNewDocumentAsync(document);

                    SetAlert("Thêm thông tin thành công!", "success");

                    return(RedirectToAction("Index"));
                }
                else if (submit == "Cập Nhật")
                {
                    isAddNew = false;

                    var document = await _documentService.GetByIdAsync(model.ID);

                    document.Title        = model.Title;
                    document.Description  = model.Description;
                    document.ModifiedDate = DateTimeHelper.GetCurrentDateTime();
                    document.FilePath     = model.FilePath;

                    await _documentService.UpdateDocumentAsync(document);

                    SetAlert("Cập nhật thông tin thành công!", "success");
                    return(RedirectToAction("Index"));
                }
            }

            return(RedirectToAction("Index"));
        }