public int Insert(LoanuserViewModels item) { // throw new NotImplementedException(); var newloan = new Loanusers() { FirstName = item.FirstName, LastName = item.LastName, Phoneno = item.Phoneno, address = item.address, Loanstatus = item.Loanstatus, ImagePath = item.ImagePath, }; _db.Loanusers.Add(newloan); _db.SaveChanges(); return(newloan.Id); }
public List <LoanuserViewModels> GetAll() { //var allloanusers = _db.Loanusers.ToList(); //return allloanusers; Loanusers lu = new Loanusers(); var loans = new List <LoanuserViewModels>(); var allbooks = (from iint in _db.Loanusers join n in _db.loanDetails on iint.Id equals n.LoanusersId select new { iint.Id, iint.ImagePath, iint.FirstName, iint.LastName, iint.Phoneno, iint.Loanstatus, iint.address } ).ToList(); if (allbooks?.Any() == true) { foreach (var loan1 in allbooks) { loans.Add(new LoanuserViewModels() { Id = loan1.Id, ImagePath = loan1.ImagePath, FirstName = loan1.FirstName, LastName = loan1.LastName, Phoneno = loan1.Phoneno, Loanstatus = loan1.Loanstatus, address = loan1.address }); } } return(loans); }
public IActionResult Insert(LoanuserViewModels item) { var newloan = new Loanusers() { FirstName = item.lu.FirstName, LastName = item.lu.LastName, Phoneno = item.lu.Phoneno, address = item.lu.address, Loanstatus = item.lu.Loanstatus, ImagePath = item.lu.ImagePath, }; int id = _loanServiceemployee.Insert(newloan); //var BikeId = BikeVM.Bike.Id; var loanid = id; string wwrootPath = _hostingenvironment.WebRootPath; var files = HttpContext.Request.Form.Files; var savedBike = _db.Loanusers.Find(loanid); if (files.Count != 0) { var ImagePath = @"images"; var Extension = Path.GetExtension(files[0].FileName); var RelativeImagePath = ImagePath + loanid + Extension; var AbsImagePath = Path.Combine(wwrootPath, RelativeImagePath); using (var filestream = new FileStream(AbsImagePath, FileMode.Create)) { files[0].CopyTo(filestream); } savedBike.ImagePath = RelativeImagePath; _db.SaveChanges(); } return(View(Luvm)); }
public int Update(Loanusers item, int id) { throw new NotImplementedException(); }