public IActionResult SearchStore(string search, float Latitude, float Longitude) { String errMessage = ""; int errorCode = 0; String[] ouput = null; object[] value = new object[] { Latitude, Longitude }; List <DrugStore> lst = DrupStoreRes.GetAllSearch(value, ref ouput, ref errorCode, ref errMessage); ViewBag.search = search; ViewBag.Latitude = Latitude; ViewBag.Longitude = Longitude; List <DrugStore> lst1 = DrupStoreRes.GetTopfive(); ViewData["Topfive"] = lst1; ViewData["aaaaaaa"] = lst; ViewBag.search = search; int total = DrupStoreRes.GetAll().Count(i => i.status == 1); var pageSize = 5; int page; page = 1; var skip = pageSize * (page - 1); var canPage = skip < total; List <DrugStore> lsttest = lst.Skip(skip).Take(pageSize).ToList(); int pagetotal = FunctionUtility.CalcTotalPage(total, 5); ViewBag.page = pagetotal; return(View(lsttest)); }
public IActionResult CommentDetailDrugStore(int id) { List <Comment> lst = DrupStoreRes.GetAllCmt().Where(i => i.storeId == id).ToList(); ViewData["storeId"] = id; return(View(lst)); }
public IActionResult SearchStore(int id) { int total = DrupStoreRes.GetAll().Count(i => i.status == 1); var pageSize = 5; int page; if (id == null) { page = 1; } else { page = id; } var skip = pageSize * (page - 1); var canPage = skip < total; List <DrugStore> lst = DrupStoreRes.GetAll().Where(a => a.status == 1).Skip(skip).Take(pageSize).ToList(); int pagetotal = FunctionUtility.CalcTotalPage(total, 5); ViewBag.page = pagetotal; List <DrugStore> lst1 = DrupStoreRes.GetTopfive().ToList(); List <District> dis = DistrictRes.GetAll(); List <DrugCategory> Category = DrugCategoryRes.GetAll(); ViewData["Category"] = Category; ViewData["Distrist"] = dis; ViewData["Topfive"] = lst1; return(View(lst)); }
public IActionResult Index() { List <DrugStore> lst = DrupStoreRes.GetAll(); if (((ClaimsIdentity)User.Identity).FindFirst("GroupId").Value == "1") { lst = DrupStoreRes.GetAll(); } else { lst = DrupStoreRes.GetAll().Where(i => i.iduser.ToString() == ((ClaimsIdentity)User.Identity).FindFirst("UserId").Value&& i.status == 1).ToList(); } var listloainhathuoc = DrugCategoryRes.GetAll(); var map = new Dictionary <int, string>(); foreach (var list in listloainhathuoc) { map.Add(list.categoryId, list.categoryName); } ViewBag.list = map; var listdistrict = DistrictRes.GetAll(); ViewBag.listdistric = listdistrict; return(View(lst)); }
public async Task <IActionResult> UpdateStore(DrugStore model, IFormFile file) { var listloainhathuoc = DrugCategoryRes.GetAll(); ViewBag.listloai = listloainhathuoc.Select(x => new SelectListItem { Text = x.categoryName, Value = x.categoryId.ToString() }).ToList(); var listdistrict = DistrictRes.GetAll(); ViewBag.listdistrict = listdistrict.Select(x => new SelectListItem { Text = x.Name, Value = x.ID.ToString() }).ToList(); if (ModelState.IsValid) { if (file != null && file.Length > 0) { var fileName = Path.GetFileName(file.FileName); string type = fileName.Substring(fileName.IndexOf(".")); if (type.Equals(".jpg") || type.Equals(".png") || type.Equals(".gif") || type.Equals(".jpeg")) { var filePath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot\\upload", fileName); using (var fileSteam = new FileStream(filePath, FileMode.Create)) { await file.CopyToAsync(fileSteam); } model.imgSrc = fileName; } else if (model.imgSrc == null) { TempData["AlertMessageError"] = "Vui lòng Chọn Đúng file ảnh "; return(RedirectToAction("UpdateStore", new { @id = model.ID })); } } DateTime dt = DateTime.Parse(model.openTime); string openTime = dt.ToString("HH:mm:ss"); DateTime dt1 = DateTime.Parse(model.closedTime); string closedTime = dt1.ToString("HH:mm:ss"); object[] value = new object[] { model.ID, "" + model.name, "" + model.address, "" + model.phone, "" + model.district, "" + model.imgSrc, model.status, model.categoryId, "" + model.description, "" + openTime, "" + closedTime, "" + model.lat, "" + model.lng }; String errMessage = ""; int errorCode = 0; String[] ouput = null; bool result = DrupStoreRes.SaveStore(value, ref ouput, ref errorCode, ref errMessage); if (result) { TempData["AlertMessage"] = "Cập nhật Nhà Thuốc Thành Công"; return(RedirectToAction("ListStore")); } } return(View(model)); }
public IActionResult DetailStore(int id, string Search) { List <DrugStore> lst1 = DrupStoreRes.GetTopfive().Take(4).ToList(); ViewData["Topfive"] = lst1; DrugStore lst = DrupStoreRes.GetAll().Where(i => i.ID == id).FirstOrDefault(); ViewBag.search = Search; //code moi ViewData["lat"] = lst.lat; ViewData["lng"] = lst.lng; ViewData["storeid"] = id; ViewData["phone"] = lst.phone; ViewData["name"] = lst.name; ViewData["imgSrc"] = lst.imgSrc; ViewData["opentime"] = lst.openTime; ViewData["closedtime"] = lst.closedTime; ViewData["description"] = lst.description; ViewData["address"] = lst.address; List <Comment> lstcmt = DrupStoreRes.GetAllCmt().Where(i => i.storeId == id).ToList(); ViewData["countCmt"] = lstcmt.Count; ViewData["comments"] = lstcmt; int sum = 0; for (int i = 0; i < lstcmt.Count; i++) { sum += lstcmt[i].rating; } int count = 0; if (lstcmt.Count == 0) { count = 1; } else { count = lstcmt.Count; } ViewData["average"] = sum / count; List <DrugDetails> detail = DetailDrugStoreRes.GetAll().Where(i => i.iddrugstore == id).ToList(); ViewData["detail"] = detail; List <Comment> lstcmt1 = DrupStoreRes.GetAllCmt().Where(i => i.storeId == id && i.rating == 4).ToList(); ViewData["dem4"] = lstcmt1.Count; return(View()); }
public ActionResult DeleteStore(int id) { object[] value = new object[] { id }; String errMessage = ""; int errorCode = 0; String[] ouput = null; bool result = DrupStoreRes.DeleteStore(value, ref ouput, ref errorCode, ref errMessage); return(RedirectToAction("ListStore")); }
public IActionResult CommentDetailDeleteDrugStore(int id) { object[] value = { id }; var errorCode = 0; var errorMessage = ""; string[] output = { }; Comment store = DrupStoreRes.GetAllCmt().Where(i => i.cid == id).FirstOrDefault(); var result = DrupStoreRes.DeleteComment(value, ref output, ref errorCode, ref errorMessage); if (result) { TempData["AlertMessage"] = "Xóa Bình luận Thành Công"; } return(RedirectToAction("CommentDetailDrugStore", new { @id = store.storeId })); }
public IActionResult DetailUserDrugStore(int id) { DrugStore store = DrupStoreRes.GetAll().Where(i => i.iduser == id).FirstOrDefault(); if (store != null) { List <DrugDetails> lst = DetailDrugStoreRes.GetAll().Where(i => i.iddrugstore == store.ID).ToList(); return(RedirectToAction("DetailDrugStore", new { @id = store.ID })); } else { TempData["AlertMessageError"] = "Không có dữ liệu nhà thuốc "; return(RedirectToAction("ListAccount", "Account")); } return(View()); }
public IActionResult Index() { List <DrugStore> listall = DrupStoreRes.GetAll().Where(a => a.status == 1).Take(5).ToList(); var listloainhathuoc = DrugCategoryRes.GetAll(); var map = new Dictionary <int, string>(); foreach (var list in listloainhathuoc) { map.Add(list.categoryId, list.categoryName); } ViewBag.list = map; List <DrugStore> lst = DrupStoreRes.GetTopfive().ToList(); ViewData["Topfive"] = lst; return(View(listall)); }
public ActionResult UpdateStore(int id) { DrugStore lstid = DrupStoreRes.GetAll().Where(i => i.ID == id).FirstOrDefault(); var listloainhathuoc = DrugCategoryRes.GetAll(); ViewBag.listloai = listloainhathuoc.Select(x => new SelectListItem { Text = x.categoryName, Value = x.categoryId.ToString() }).ToList(); var listdistrict = DistrictRes.GetAll(); ViewBag.listdistrict = listdistrict.Select(x => new SelectListItem { Text = x.Name, Value = x.ID.ToString() }).ToList(); return(View(lstid)); }
public ActionResult CommentOnStore(Comment model, int id) { DateTime datetime = DateTime.Now; if (ModelState.IsValid) { object[] value = new object[] { model.cid, "" + model.name, "" + model.email, "" + model.comment, "" + datetime, "" + model.rating, "" + id }; String errMessage = ""; int errorCode = 0; String[] ouput = null; string kaa = model.cid + "" + model.name + "" + model.email + "" + model.comment + "" + datetime + "" + model.rating + "id nha thuoc" + id; bool result = DrupStoreRes.SaveComment(value, ref ouput, ref errorCode, ref errMessage); if (result) { TempData["AlertMessage"] = "Cập nhật Bình Luận Thành Công"; return(RedirectToAction("DetailStore" + "/" + id, "HomeDrugStore")); } } return(View()); }