public async Task <int> CreateAsync(storedetails obj) { await _context.storedetails.AddAsync(obj); await _context.SaveChangesAsync(); return(obj.id); }
public async Task <IActionResult> ContactPersonDetails(StoreDetailContactPersonDetails model) { if (ModelState.IsValid) { ApplicationUser usr = await GetCurrentUserAsync(); var id = usr.Id; // var idd = storedetailsServices.GetAll().Where(x => x.storeid == id).FirstOrDefault().id; var store = storedetailsServices.GetAll().Where(x => x.storeid == id).FirstOrDefault(); if (store == null) { var details = new storedetails { storeid = id, // id = model.id, contactpersonname = model.contactpersonname, emailaddress = model.emailaddress, gender = model.gender, contactno = model.contactno, isdeleted = false // cityid=0 // deliverytimeid = 0, // radiusid = 0 }; await storedetailsServices.CreateAsync(details); } else { //store.id = idd; store.contactpersonname = model.contactpersonname; store.emailaddress = model.emailaddress; store.gender = model.gender; store.contactno = model.contactno; await storedetailsServices.UpdateAsync(store); } TempData["success"] = "Record Saved Successfully"; return(RedirectToAction("ContactPersonDetails")); //return RedirectToAction("Index", "Home"); } else { return(View(model)); } }
public async Task <IActionResult> Services(StoreDetailServicesDetails model) { if (ModelState.IsValid) { ApplicationUser usr = await GetCurrentUserAsync(); var id = usr.Id; // var idd = storedetailsServices.GetAll().Where(x => x.storeid == id).FirstOrDefault().id; var store = storedetailsServices.GetAll().Where(x => x.storeid == id).FirstOrDefault(); if (store == null) { var details = new storedetails { storeid = id, // id = model.id, fooddelivery = model.fooddelivery, contactpersonname = "", isdeleted = false, // deliverytimeid = 0, // radiusid = 0 }; await storedetailsServices.CreateAsync(details); } else { //store.id = idd; store.fooddelivery = model.fooddelivery; await storedetailsServices.UpdateAsync(store); } return(RedirectToAction("Index", "Home")); } else { return(View(model)); } }
public async Task <IActionResult> Documentation(storedetaildocumentationviewmodel model) { if (ModelState.IsValid) { ApplicationUser usr = await GetCurrentUserAsync(); var id = usr.Id; // var idd = storedetailsServices.GetAll().Where(x => x.storeid == id).FirstOrDefault().id; var store = storedetailsServices.GetAll().Where(x => x.storeid == id).FirstOrDefault(); if (store == null) { var details = new storedetails { storeid = id, contactpersonname = "", isdeleted = false, }; if (model.licPhoto != null && model.licPhoto.Length > 0) { var uploadDir = @"uploads/storeBannerPhoto"; var fileName = Path.GetFileNameWithoutExtension(model.licPhoto.FileName); var extesion = Path.GetExtension(model.licPhoto.FileName); var webRootPath = _hostingEnvironment.WebRootPath; if (details.licPhoto != null) { var imagePath = webRootPath + details.licPhoto.ToString().Replace("/", "\\"); if (System.IO.File.Exists(imagePath)) { System.IO.File.Delete(imagePath); } } fileName = DateTime.UtcNow.ToString("yymmssfff") + fileName + extesion; var path = Path.Combine(webRootPath, uploadDir, fileName); // await model.licPhoto.CopyToAsync(new FileStream(path, FileMode.Create)); FileStream fs = new FileStream(path, FileMode.Create); await model.licPhoto.CopyToAsync(fs); fs.Close(); details.licPhoto = '/' + uploadDir + '/' + fileName; } await storedetailsServices.CreateAsync(details); } else { // storename, radiusid, deliverytimeid, orderMinAmount, packagingCharges, storeBannerPhoto, //address, description, storetim //store.id = idd; var webRootPath = _hostingEnvironment.WebRootPath; if (store.licPhoto != null) { var imagePath = webRootPath + store.licPhoto.ToString().Replace("/", "\\"); if (System.IO.File.Exists(imagePath)) { System.IO.File.Delete(imagePath); } } var uploadDir = @"uploads/licPhoto"; var fileName = Path.GetFileNameWithoutExtension(model.licPhoto.FileName); var extesion = Path.GetExtension(model.licPhoto.FileName); fileName = DateTime.UtcNow.ToString("yymmssfff") + fileName + extesion; var path = Path.Combine(webRootPath, uploadDir, fileName); // await model.licPhoto.CopyToAsync(new FileStream(path, FileMode.Create)); FileStream fs = new FileStream(path, FileMode.Create); await model.licPhoto.CopyToAsync(fs); fs.Close(); store.licPhoto = '/' + uploadDir + '/' + fileName; await storedetailsServices.UpdateAsync(store); } TempData["success"] = "Record Saved Successfully"; return(RedirectToAction("Documentation")); //return RedirectToAction("Index", "Home"); } else { return(View(model)); } }
public async Task <IActionResult> StoreDetails(StoreDetailsViewModel model) { if (ModelState.IsValid) { ApplicationUser usr = await GetCurrentUserAsync(); var id = usr.Id; // var idd = storedetailsServices.GetAll().Where(x => x.storeid == id).FirstOrDefault().id; var store = storedetailsServices.GetAll().Where(x => x.storeid == id).FirstOrDefault(); if (store == null) { var details = new storedetails { storeid = id, storename = model.storename, contactpersonname = "", // id = model.id, radiusid = model.radiusid, deliverytimeid = model.deliverytimeid, orderMinAmount = model.orderMinAmount, packagingCharges = model.packagingCharges, isdeleted = false, address = model.address, description = model.description, //storetime = model.storetime, storetime = model.FromTime + " - " + model.ToTime, latitude = model.latitude, longitude = model.longitude, cityid = model.cityid, promocode = model.promocode, discount = model.discount, accountno = model.longitude, banklocation = model.banklocation, bankname = model.bankname, ifsccode = model.ifsccode, status = model.status, adminCommissionPer = model.adminCommissionPer, taxstatus = model.taxstatus, taxstatusPer = model.taxstatusPer // deliverytimeid = 0, // radiusid = 0 }; if (model.storeBannerPhoto != null && model.storeBannerPhoto.Length > 0) { var uploadDir = @"uploads/storeBannerPhoto"; var fileName = Path.GetFileNameWithoutExtension(model.storeBannerPhoto.FileName); var extesion = Path.GetExtension(model.storeBannerPhoto.FileName); var webRootPath = _hostingEnvironment.WebRootPath; if (store.storeBannerPhoto != null) { var imagePath = webRootPath + store.storeBannerPhoto.ToString().Replace("/", "\\"); if (System.IO.File.Exists(imagePath)) { System.IO.File.Delete(imagePath); } } fileName = DateTime.UtcNow.ToString("yymmssfff") + fileName + extesion; var path = Path.Combine(webRootPath, uploadDir, fileName); // await model.storeBannerPhoto.CopyToAsync(new FileStream(path, FileMode.Create)); FileStream fs = new FileStream(path, FileMode.Create); await model.storeBannerPhoto.CopyToAsync(fs); fs.Close(); details.storeBannerPhoto = '/' + uploadDir + '/' + fileName; } await storedetailsServices.CreateAsync(details); } else { // storename, radiusid, deliverytimeid, orderMinAmount, packagingCharges, storeBannerPhoto, //address, description, storetim //store.id = idd; store.storename = model.storename; store.radiusid = model.radiusid; store.deliverytimeid = model.deliverytimeid; store.orderMinAmount = model.orderMinAmount; store.packagingCharges = model.packagingCharges; store.address = model.address; store.description = model.description; // store.storetime = model.storetime; store.storetime = model.FromTime + " - " + model.ToTime; store.latitude = model.latitude; store.longitude = model.longitude; store.cityid = model.cityid; store.promocode = model.promocode; store.discount = model.discount; store.bankname = model.bankname; store.banklocation = model.banklocation; store.accountno = model.accountno; store.ifsccode = model.ifsccode; store.status = model.status; store.adminCommissionPer = model.adminCommissionPer; store.taxstatus = model.taxstatus; store.taxstatusPer = model.taxstatusPer; if (model.storeBannerPhoto != null && model.storeBannerPhoto.Length > 0) { if (!string.IsNullOrEmpty(store.storeBannerPhoto)) { try { var filePath1 = _hostingEnvironment.WebRootPath + store.storeBannerPhoto.ToString().Replace("/", "\\"); FileInfo file = new FileInfo(filePath1); if (file.Exists) { file.Delete(); } } catch { } } var uploadDir = @"uploads/storeBannerPhoto"; var fileName = Path.GetFileNameWithoutExtension(model.storeBannerPhoto.FileName); var extesion = Path.GetExtension(model.storeBannerPhoto.FileName); var webRootPath = _hostingEnvironment.WebRootPath; if (store.storeBannerPhoto != null) { var imagePath = webRootPath + store.storeBannerPhoto.ToString().Replace("/", "\\"); if (System.IO.File.Exists(imagePath)) { System.IO.File.Delete(imagePath); } } fileName = DateTime.UtcNow.ToString("yymmssfff") + fileName + extesion; var path = Path.Combine(webRootPath, uploadDir, fileName); // await model.storeBannerPhoto.CopyToAsync(new FileStream(path, FileMode.Create)); FileStream fs = new FileStream(path, FileMode.Create); await model.storeBannerPhoto.CopyToAsync(fs); fs.Close(); store.storeBannerPhoto = '/' + uploadDir + '/' + fileName; } await storedetailsServices.UpdateAsync(store); } TempData["success"] = "Record Saved Successfully"; return(RedirectToAction("StoreDetails")); //return RedirectToAction("Index", "Home"); } else { ViewBag.Countries = _CountryRegistrationservices.GetAll().ToList(); ViewBag.radiusList = _RadiusMasterServices.GetAll().ToList(); ViewBag.deliveryList = _DeliveryTimeMasterServices.GetAll().ToList(); return(View(model)); } }
public async Task <IActionResult> updateStoreStatus(string storeId, string status) { try { try { var store = _storedetailsServices.GetAll().Where(x => x.storeid == storeId).FirstOrDefault(); if (store == null) { var details = new storedetails { storeid = storeId, status = status }; int id = await _storedetailsServices.CreateAsync(details); var store1 = _storedetailsServices.GetById(id); return(Ok(store1)); } else { //var store1 = _storedetailsServices.GetAll().Where(x => x.storeid == storeId).FirstOrDefault(); if (store == null) { } else { store.status = status; await _storedetailsServices.UpdateAsync(store); return(Ok(store)); } } } catch (Exception obj) { //var details = new storedetails //{ // storeid = storeId, // storename = "", // contactpersonname = "", // // id = model.id, // radiusid = 0, // deliverytimeid = 0, // orderMinAmount =0, // packagingCharges =0, // isdeleted = false, // address ="", // description = "", // //storetime = model.storetime, // storetime = "", // latitude = "", // longitude = "", // cityid = 0, // promocode = "", // discount =0, // accountno = "", // banklocation = "", // bankname = "", // ifsccode = "", // status = status, // adminCommissionPer =0, // taxstatus = "", // taxstatusPer = 0 //}; //await _storedetailsServices.CreateAsync(details); //var store = _storedetailsServices.GetAll().Where(x => x.storeid == storeId).FirstOrDefault(); //return Ok(store); } finally { } // IEnumerable<storedetails> store = _storedetailsServices.GetAll().Where(x => x.storeid == storeId); return(BadRequest()); //if (store == null) //{ // var details = new storedetails // { // storeid = storesId, // status=status // //storename = "", // //contactpersonname = "", // //radiusid = model.radiusid, // //deliverytimeid = model.deliverytimeid, // //orderMinAmount = model.orderMinAmount, // //packagingCharges = model.packagingCharges, // //isdeleted = false, // //address = model.address, // //description = model.description, // ////storetime = model.storetime, // //storetime = model.FromTime + " - " + model.ToTime, // //latitude = model.latitude, // //longitude = model.longitude, // //cityid = model.cityid, // //promocode = model.promocode, // //discount = model.discount, // //accountno = model.longitude, // //banklocation = model.banklocation, // //bankname = model.bankname, // //ifsccode = model.ifsccode, // //status = model.status, // //adminCommissionPer = model.adminCommissionPer, // //taxstatus = model.taxstatus, // //taxstatusPer = model.taxstatusPer // }; // await _storedetailsServices.CreateAsync(details); // return Ok(store); //} //else //{ // store.status = status; // await _storedetailsServices.UpdateAsync(store); // return Ok(store); //} } catch (Exception obj) { return(Ok(obj.Message)); } }
public async Task UpdateAsync(storedetails obj) { _context.storedetails.Update(obj); await _context.SaveChangesAsync(); }