Hi,
I know how to save form inputs data directly into database but l dont know the code one can save image in binary format into database. And l aslo want to load my angular grid with data from the database including image. Below is my codes
|
public IActionResult UrlDatasource([FromBody] DataManagerRequest dm) { IEnumerable DataSource = _context.Customer.ToList(); DataOperations operation = new DataOperations(); if (dm.Search != null && dm.Search.Count > 0) { DataSource = operation.PerformSearching(DataSource, dm.Search); //Search } if (dm.Sorted != null && dm.Sorted.Count > 0) //Sorting { DataSource = operation.PerformSorting(DataSource, dm.Sorted); } if (dm.Where != null && dm.Where.Count > 0) //Filtering { DataSource = operation.PerformFiltering(DataSource, dm.Where, dm.Where[0].Operator); } int count = DataSource.Cast<Customer>().Count(); if (dm.Skip != 0) { DataSource = operation.PerformSkip(DataSource, dm.Skip); //Paging } if (dm.Take != 0) { DataSource = operation.PerformTake(DataSource, dm.Take); } return dm.RequiresCounts ? Json(new { result = DataSource, count = count }) : Json(DataSource); }
public ActionResult Insert([FromBody] ICRUDModel<Customer> value) { _context.Customer.Add(value.Value); _context.SaveChanges(); return Json(value); }
public IActionResult Update([FromBody] ICRUDModel<Customer> value) { var ord = value; Customer val = _context.Customer.Where(or => or.CustomerId == ord.Value.CustomerId).FirstOrDefault(); val.CustomerId = ord.Value.CustomerId; val.Company = ord.Value.Company; val.CustomerName = ord.Value.CustomerName; val.Prefix = ord.Value.Prefix; val.CustomerSegment = ord.Value.CustomerSegment; val.Photo = ord.Value.Photo; _context.SaveChanges(); return Json(value); }
public IActionResult Delete([FromBody] ICRUDModel<Customer> value) { Customer order = _context.Customer.Where(c => c.CustomerId == (int)value.key).FirstOrDefault(); _context.Customer.Remove(order); _context.SaveChanges(); return Json(order); } |
Regards
Char
Hi Charles,
Before providing a solution, we need some more details that will be helpful for us to validate the scenario and share a better solution. So please share the below information.
Regards,
Pavithra S