public bool Delete(Guid id) { var db = new ClockStoreContext(); var file = new ClockStoreContext().File.Find(id); db.Entry(file).State = EntityState.Deleted; db.File.Remove(file); return(db.SaveChanges() > 0); }
public static FileResult VideoHandler(Guid fileId) { ClockStoreContext db = new ClockStoreContext(); var file = db.File.FirstOrDefault(x => x.FileId == fileId); if (file != null) { FileContentResult res = new FileContentResult(file.Context, file.ContextType); res.FileDownloadName = file.Title; return(res); } return(null); }
public static string ImageHandler(Guid fileId) { ClockStoreContext db = new ClockStoreContext(); var file = db.File.FirstOrDefault(x => x.FileId == fileId); if (file != null) { var base64 = Convert.ToBase64String(file.Context); var imagesrc = string.Format("data:image/gif;base64,{0}", base64); return(imagesrc); //return File(model.Context, "image/jpg"); } return(string.Empty); }
public bool UpDate(Guid id, HttpPostedFileBase image) { var file = new ClockStoreContext().File.Find(id); if (file != null) { file.Context = new byte[image.ContentLength]; image.InputStream.Read(file.Context, 0, image.ContentLength); file.ContextType = image.ContentType; file.Title = image.FileName; //new ClockStoreContext().Entry(file).State = EntityState.Modified; //return new ClockStoreContext().SaveChanges() > 0; base.Update(file); base.Dispose(); } return(false); }
public File NewsInsert(HttpPostedFileBase image) { var file = new File(); file.FileId = Guid.NewGuid(); if (image != null) { file.Context = new byte[image.ContentLength]; image.InputStream.Read(file.Context, 0, image.ContentLength); file.ContextType = image.ContentType; file.Title = image.FileName; } var d = new ClockStoreContext(); d.File.Add(file); return(file); }
public static void ClearBasket(Guid customerId) { var db = new ClockStoreContext(); var list = db.Basket.ToList().Where(c => c.CustomerId == customerId && c.IsArchive == false); if (list != null) { foreach (var item in list) { if (item.Product.IsBlocked.HasValue && item.Product.IsBlocked.Value) { item.Product.IsBlocked = false; db.Entry(item.Product).State = EntityState.Modified; db.SaveChanges(); } db.Basket.Remove(item); db.SaveChanges(); } } }
public BaseBO() { db = new ClockStoreContext(); }