public static List <DrugStore> GetTopfive() { List <DrugStore> lstStore = new List <DrugStore>(); object[] value = null; var connection = new SQLCommand(ConstValue.ConnectionString); var result = connection.Select("topfive_Rating", value); if (connection.errorCode == 0 && result.Rows.Count > 0) { foreach (DataRow dr in result.Rows) { DrugStore store = new DrugStore() { ID = int.Parse(dr["ID"].ToString()), name = dr["name"].ToString(), address = dr["address"].ToString(), district = int.Parse(dr["district"].ToString()), imgSrc = dr["imgSrc"].ToString(), openTime = dr["openTime"].ToString(), closedTime = dr["closedTime"].ToString(), averageRating = int.Parse(dr["AverageRating"].ToString()) }; lstStore.Add(store); } } return(lstStore); }
public static List <DrugStore> GetAllSearch(object[] value, ref string[] output, ref int errorCode, ref string errorMessage) { List <DrugStore> lstStore = new List <DrugStore>(); var connection = new SQLCommand(ConstValue.ConnectionString); var result = connection.Select("DrugStore_GetallSearch", value); if (connection.errorCode == 0 && result.Rows.Count > 0) { foreach (DataRow dr in result.Rows) { DrugStore store = new DrugStore() { ID = int.Parse(dr["ID"].ToString()), name = dr["name"].ToString(), address = dr["address"].ToString(), district = int.Parse(dr["district"].ToString()), phone = dr["phone"].ToString(), imgSrc = dr["imgSrc"].ToString(), status = int.Parse(dr["status"].ToString()), categoryId = int.Parse(dr["categoryId"].ToString()), openTime = dr["openTime"].ToString(), closedTime = dr["closedTime"].ToString(), averageRating = int.Parse(dr["AverageRating"].ToString()) }; lstStore.Add(store); } } return(lstStore); }
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 void AddDrugsToTheStore(int storeId, int drugId) { var entity = new DrugStore { StoresId = storeId, DrugsId = drugId }; _application.Set <DrugStore>().Add(entity); }
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 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 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 List<DrugStore> GetDrugStoreByWardID(int id) { List<DrugStore> list_store = new List<DrugStore> (); var cursor = db.getStoreByWardId (id); if (cursor.MoveToFirst ()) { for (int i = 0; i < cursor.Count; i++) { DrugStore item = new DrugStore { id = cursor.GetInt (0), name = cursor.GetString (1), address = new Address { id = cursor.GetInt (2), number = cursor.GetString (3), street = new Street { id = cursor.GetInt (4), name = cursor.GetString (5), }, ward = new Ward { id = cursor.GetInt (6), name = cursor.GetString (7), }, disctrict = new District { id = cursor.GetInt (8), name = cursor.GetString (9) } } }; list_store.Add (item); cursor.MoveToNext (); } return list_store; } return list_store; }
public DetailDialogFragment(DrugStore item, Context context) { this.context = context; store = item; }
public MapController() { store = new DrugStore (); viewModel = ServiceContainer.Resolve<MainViewModel> (); viewModel.DAL = AppController.getDAl (); }
public ActionResult DrugStoreGetId(int id) { DEntity <DrugStore> e = new DEntity <DrugStore>(ConstValue.ConnectionString, DrugStore.getTableName()); return(Json(e.get("ID", id))); }
public IActionResult ListDrugStore() { DEntity <DrugStore> e = new DEntity <DrugStore>(ConstValue.ConnectionString, DrugStore.getTableName()); return(Json(e.getAll())); }