public async Task <IActionResult> Create(productcuisineCreateViewModel model) { if (ModelState.IsValid) { //ApplicationUser usr = await GetCurrentUserAsync(); //var id = usr.Id; var store = new productcuisinemaster { id = model.id , name = model.name // , profilephoto=model.profilephoto , isdeleted = false , isactive = false }; if (model.img != null && model.img.Length > 0) { var uploadDir = @"uploads/cuisine"; var fileName = Path.GetFileNameWithoutExtension(model.img.FileName); var extesion = Path.GetExtension(model.img.FileName); var webRootPath = _hostingEnvironment.WebRootPath; fileName = DateTime.UtcNow.ToString("yymmssfff") + fileName + extesion; var path = Path.Combine(webRootPath, uploadDir, fileName); //await model.img.CopyToAsync(new FileStream(path, FileMode.Create)); FileStream fs = new FileStream(path, FileMode.Create); await model.img.CopyToAsync(fs); fs.Close(); store.img = '/' + uploadDir + '/' + fileName; } await _productcuisinemasterservices.CreateAsync(store); TempData["success"] = "Record Save successfully"; return(RedirectToAction(nameof(Index))); } else { return(View()); } }
//public radiusmaster GetById(int id) => // _context.radiusmaster.Where(x => x.id == id).FirstOrDefault(); public async Task UpdateAsync(productcuisinemaster obj) { _context.productcuisinemaster.Update(obj); await _context.SaveChangesAsync(); }
//------ public void Updatestatus(productcuisinemaster obj) { _context.productcuisinemaster.Update(obj); _context.SaveChanges(); }
public async Task CreateAsync(productcuisinemaster obj) { await _context.productcuisinemaster.AddAsync(obj); await _context.SaveChangesAsync(); }