protected override void OnModelCreating(ModelBuilder modelBuilder) { Database.EnsureCreated(); TeamMember.Configure(modelBuilder); IndexImage.Configure(modelBuilder); }
public void Delete(string id) { ObjectId oid = ObjectId.Parse(id); IndexImage info = client.FindOne <IndexImage>(new { _id = oid }); client.DeleteOneById <IndexImage>(info); }
// GET: IndexImageUpdate public ActionResult Index(string id) { ObjectId oid = ObjectId.Parse(id); IndexImage info = client.FindOne <IndexImage>(new { _id = oid }); if (info == null) { info = new IndexImage(); } return(View(info)); }
public ActionResult Index(HttpPostedFileWrapper file, string imgnames) { string imgname = Guid.NewGuid().ToString() + ".jpg"; string imgpath = Server.MapPath("~/upload/image/" + imgname); file.SaveAs(imgpath); IndexImage fileimg = new IndexImage(); fileimg.file = "/upload/image/" + imgname; fileimg.Language = Language; fileimg.Name = imgnames; client.InsertOne(fileimg); return(RedirectToAction("Index")); }
public ActionResult Index(HttpPostedFileWrapper file, string _id, string imgnames) { string imgname = Guid.NewGuid().ToString() + ".jpg"; ObjectId oid = ObjectId.Parse(_id); string imgpath = Server.MapPath("~/upload/image/" + imgname); file.SaveAs(imgpath); IndexImage fileimg = client.FindOne <IndexImage>(new { _id = oid }); fileimg.file = "/upload/image/" + imgname; fileimg.Language = Language; fileimg.Name = imgnames; client.UpdateOneById(fileimg); return(RedirectToAction("Index", new { id = _id })); }
public List <IndexImage> ImgList(int pageIndex, int pageSize, out int pageCount, out int recordCount) { string sql = "usp_Img"; List <IndexImage> list = new List <IndexImage>(); SqlParameter[] pms = new SqlParameter[] { new SqlParameter("@pageIndex", SqlDbType.Int) { Value = pageIndex }, new SqlParameter("@pageSize", SqlDbType.Int) { Value = pageSize }, new SqlParameter("@pageCount", SqlDbType.Int) { Direction = ParameterDirection.Output }, new SqlParameter("@recordCount", SqlDbType.Int) { Direction = ParameterDirection.Output } }; using (SqlDataReader reader = SqlHelper.ExecuteReader(sql, CommandType.StoredProcedure, pms)) { if (reader.HasRows) { while (reader.Read()) { IndexImage img = new IndexImage(); img.ImgId = reader.GetInt32(0); img.ImgUrl = reader.GetString(1); list.Add(img); } } } pageCount = Convert.ToInt32(pms[2].Value); recordCount = Convert.ToInt32(pms[3].Value); return(list); }
public async Task AddImageAsync(IndexImage image) { await _dbContext.IndexImages.AddAsync(image); await SaveChanges(); }