Exemplo n.º 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;
     }
 }
Exemplo n.º 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;
     }
 }
Exemplo n.º 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;
            }
        }
Exemplo n.º 4
0
        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");
        }
Exemplo n.º 5
0
        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");

        }
Exemplo n.º 6
0
 public Enum.EntityResult Disable(Document disable)
 {
     disable.Active = false;
     return Update(disable);
 }