public Enum.EntityResult Update(Media modified) { try { _db.Entry(modified).State = EntityState.Modified; _db.SaveChanges(); return Enum.EntityResult.Success; } catch (Exception r) { return Enum.EntityResult.Failed; } }
public Enum.EntityResult Delete(Media delete) { try { _db.Medias.Remove(delete); _db.SaveChanges(); return Enum.EntityResult.Success; } catch (Exception) { return Enum.EntityResult.Failed; } }
public Enum.EntityResult Create(Media media) { try { media.Active = true; _db.Medias.Add(media); _db.SaveChanges(); return Enum.EntityResult.Success; } catch (Exception r) { return Enum.EntityResult.Failed; } }
public bool _mediaEdit(Media media) { if (!ModelState.IsValid) { this.AddToastMessage("", "Alanları kontrol edniz", Enum.ToastrType.Warning); return false; } var res = new MediaRepository().Update(media); if (res == Enum.EntityResult.Failed) { this.AddToastMessage("", "Görsel kaydedilirken hata", Enum.ToastrType.Error); return false; } this.AddToastMessage("", "Görsel kaydedildi.", Enum.ToastrType.Success); return true; }
public void AlbumMediaUpload(int albumId) { var file = Request.Files[0]; if (!(file?.ContentLength > 0)) return; var res = FileSave(file, "Media", Enum.FileType.Media); if (res == null) { this.AddToastMessage("", "Dosya yüklenirken hata!"); return; } var media = new Media { Active = true, AuthorId = new AuthenticatedAuthor().Id, CreateDateTime = DateTime.Now, FileId = res.Id, Title = res.Title }; if (new MediaRepository().Create(media) == Enum.EntityResult.Success) { if (new AlbumMediaRepository().Create(new AlbumMedia { AlbumId = albumId, MediaId = media.Id }) != Enum.EntityResult.Success) { this.AddToastMessage("", "Album kaydedilirken hata"); } } else { this.AddToastMessage("", "Album kaydedilirken hata"); } }
public HttpStatusCode MediaCreate(HttpPostedFileBase file) { //var file = Request.Files[0]; if (!(file?.ContentLength > 0)) return HttpStatusCode.NoContent; var res = FileSave(file, "Media", Enum.FileType.Media); if (res == null) { return HttpStatusCode.InternalServerError; } var media = new Media { Active = true, AuthorId = new AuthenticatedAuthor().Id, CreateDateTime = DateTime.Now, FileId = res.Id, Title = res.Title }; return new MediaRepository().Create(media) == Enum.EntityResult.Failed ? HttpStatusCode.InternalServerError : HttpStatusCode.OK; }
public ActionResult _Create(Article model, HttpPostedFileBase photo) { if (!ModelState.IsValid) { this.AddToastMessage("", "Alanları kontrol Ediniz", Enum.ToastrType.Warning); ViewBag.ArticleTypeId = new SelectList(new ArticleRepository().Types(), "Id", "Title", model.ArticleTypeId); ViewBag.PageId = new SelectList(new PageRepository().GetAll(), "Id", "Title", model.PageId); return View(model); } if (photo?.ContentLength > 0) { var photofile = FileSave(photo, "Media", Enum.FileType.Media); if (photofile != null) { var media = new Media { FileId = photofile.Id, Active = true, AuthorId = new AuthenticatedAuthor().Id, CreateDateTime = DateTime.Now, AltText = model.Title, Description = model.Title, Title = model.Title }; if (new MediaRepository().Create(media) == Enum.EntityResult.Success) { this.AddToastMessage("", "Logo yüklendi", Enum.ToastrType.Success); model.MediaId = media.Id; } else { FileDelete(photofile); this.AddToastMessage("", "Logo yüklenirken hata", Enum.ToastrType.Error); this.AddToastMessage("", "Sayfayı yenileyin ve tekrar deneyin."); } } else { this.AddToastMessage("", "Logo yüklenirken hata", Enum.ToastrType.Error); this.AddToastMessage("", "Sayfayı yenileyin ve tekrar deneyin."); } } model.Permalink = Helper.CharacterCorrection(model.Title); model.AuthorId = new AuthenticatedAuthor().Id; var res = new ArticleRepository().Create(model); if (res == Enum.EntityResult.Failed) { this.AddToastMessage("", "Makale oluşturulurken hata", Enum.ToastrType.Error); ViewBag.ArticleTypeId = new SelectList(new ArticleRepository().Types(), "Id", "Title", model.ArticleTypeId); ViewBag.PageId = new SelectList(new PageRepository().GetAll(), "Id", "Title", model.PageId); return View(model); } this.AddToastMessage("", "Kayıt Başarılı", Enum.ToastrType.Success); return RedirectToAction("Index"); }
public ActionResult Index(Settings settings, HttpPostedFileBase logoFile) { if (!ModelState.IsValid) { this.AddToastMessage("", "Alanları kontrol ediniz.", Enum.ToastrType.Warning); return View(settings); } if (logoFile?.ContentLength > 0) { var logo = FileSave(logoFile, "Media", Enum.FileType.Media); if (logo != null) { var media = new Media { FileId = logo.Id, Active = true, AuthorId = new AuthenticatedAuthor().Id, CreateDateTime = DateTime.Now, AltText = settings.Title, Description = settings.Description, Title = settings.Title }; if (new MediaRepository().Create(media) == Enum.EntityResult.Success) { this.AddToastMessage("", "Logo yüklendi", Enum.ToastrType.Success); settings.LogoId = media.Id; } else { FileDelete(logo); this.AddToastMessage("", "Logo yüklenirken hata", Enum.ToastrType.Error); this.AddToastMessage("", "Sayfayı yenileyin ve tekrar deneyin."); } } else { this.AddToastMessage("", "Logo yüklenirken hata", Enum.ToastrType.Error); this.AddToastMessage("", "Sayfayı yenileyin ve tekrar deneyin."); } } if (_repository.Update(settings) == Enum.EntityResult.Failed) { this.AddToastMessage("", "Ayarlar kaydedilirken hata", Enum.ToastrType.Error); return View(settings); } this.AddToastMessage("", "Ayarlar kaydedildi", Enum.ToastrType.Success); return RedirectToAction("Index"); }
public Enum.EntityResult Disable(Media disable) { disable.Active = false; return Update(disable); }