コード例 #1
0
 public Enum.EntityResult Update(Document modified)
 {
     try
     {
         _db.Entry(modified).State = EntityState.Modified;
         _db.SaveChanges();
         return Enum.EntityResult.Success;
     }
     catch (Exception r)
     {
         return Enum.EntityResult.Failed;
     }
 }
コード例 #2
0
 public Enum.EntityResult Delete(Document delete)
 {
     try
     {
         _db.Documents.Remove(delete);
         _db.SaveChanges();
         return Enum.EntityResult.Success;
     }
     catch (Exception)
     {
         return Enum.EntityResult.Failed;
     }
 }
コード例 #3
0
        public Enum.EntityResult Create(Document document)
        {
            try
            {
                document.Published = DateTime.Now;
                document.Active = true;
                _db.Documents.Add(document);
                _db.SaveChanges();

                return Enum.EntityResult.Success;
            }
            catch (Exception)
            {
                return Enum.EntityResult.Failed;
            }
        }
コード例 #4
0
ファイル: FilesController.cs プロジェクト: hayry26/pavlikeCMS
        public ActionResult DocumentEdit(Document modified)
        {
            if (!ModelState.IsValid)
            {
                this.AddToastMessage("", "Alanları kontrol Ediniz", Enum.ToastrType.Warning);
                return View("DocumentCreate", modified);
            }
            var res = new DocumentRepository().Update(modified);
            if (res == Enum.EntityResult.Failed)
            {
                this.AddToastMessage("", "Belge güncellenirken hata", Enum.ToastrType.Error);
                return View("DocumentCreate", modified);
            }

            this.AddToastMessage("", "Kayıt Başarılı", Enum.ToastrType.Success);
            return RedirectToAction("Documents");
        }
コード例 #5
0
ファイル: FilesController.cs プロジェクト: hayry26/pavlikeCMS
        public ActionResult DocumentCreate(Document model, HttpPostedFileBase uploadFile)
        {
            if (!ModelState.IsValid)
            {
                this.AddToastMessage("", "Alanları kontrol Ediniz", Enum.ToastrType.Warning);

                return View(model);
            }

            if (!(uploadFile?.ContentLength > 0))
            {
                this.AddToastMessage("", "Belge seçmelisiniz!", Enum.ToastrType.Error);
                return View(model);
            }
            var uploadedFile = FileSave(uploadFile, "Document", Enum.FileType.Document);
            if (uploadedFile == null)
            {
                this.AddToastMessage("", "Dosya kaydedilirken hata.", Enum.ToastrType.Error);
                return View(model);
            }

            model.AuthorId = new AuthenticatedAuthor().Id;
            model.FileId = uploadedFile.Id;
            var res = _documentRepo.Create(model);
            if (res == Enum.EntityResult.Failed)
            {
                this.AddToastMessage("", "Dosya kaydedilirken hata", Enum.ToastrType.Error);
                FileDelete(new FileRepository().FindbyId(model.FileId));
                return View(model);
            }

            this.AddToastMessage("", "Kayıt Başarılı", Enum.ToastrType.Success);
            return RedirectToAction("Documents");

        }
コード例 #6
0
 public Enum.EntityResult Disable(Document disable)
 {
     disable.Active = false;
     return Update(disable);
 }