public ActionResult Add(Category_model Model) { if (!ModelState.IsValid) { ViewBag.Parent = new SelectList(_categoryBL.GetListParent(), "id", "name"); return(View(Model)); } List <string> lstMsg = new List <string>(); int returnCode = _categoryBL.Insert(Model, out lstMsg); if (!((int)Common.ReturnCode.Succeed == returnCode)) { ViewBag.Parent = new SelectList(_categoryBL.GetListParent(), "id", "name"); if (lstMsg != null) { for (int i = 0; i < lstMsg.Count(); i++) { ModelState.AddModelError(string.Empty, lstMsg[i]); } } return(View(Model)); } TempData["Success"] = "Inserted Successfully!"; return(RedirectToAction("Index")); }
public ActionResult Add() { Category_model Model = new Category_model(); ViewBag.Parent = new SelectList(_categoryBL.GetListParent(), "id", "name"); return(View(Model)); }
public override void OnBindViewHolder(RecyclerView.ViewHolder holder, int position) { Category_model category_ModelList = modelList[position]; MyViewHolder myViewHolder = holder as MyViewHolder; if (category_ModelList.image != "" || !string.IsNullOrEmpty(category_ModelList.image)) { Glide.With(context) .Load(category_ModelList.image) .Apply(RequestOptions.CircleCropTransform()) .Into(myViewHolder.image); } preferences = context.GetSharedPreferences("lan", FileCreationMode.Private); language = preferences.GetString("language", ""); myViewHolder.title.Text = category_ModelList.title; myViewHolder.mainView.Click += delegate { string getid = modelList[position].cat_id; Intent intent = new Intent(context, typeof(CategoryPage)); intent.PutExtra("cat_id", getid); intent.PutExtra("title", modelList[position].title); intent.PutExtra("image", modelList[position].image); context.StartActivity(intent); }; }
public int Insert(Category_model model, out List <string> lstMsg) { int result = (int)Common.ReturnCode.Succeed; lstMsg = new List <string>(); try { if (isError(model, (int)Common.ActionType.Add, out lstMsg)) { return((int)Common.ReturnCode.UnSuccess); } var sql = "INSERT INTO `product_category` (`parent_id`, `code`, `name`, `description`) VALUES(@parent_id, @code, @name, @description); "; db.Execute(sql, model); } catch (Exception ex) { lstMsg.Add("Exception Occurred."); result = (int)Common.ReturnCode.UnSuccess; } return(result); }
public int GetByID(long ID, out Category_model Model) { int returnCode = (int)Common.ReturnCode.Succeed; Model = new Category_model(); try { if (ID != 0) { string sql = "SELECT *"; sql += " FROM product_category"; sql += " WHERE `id` = @id"; Model = db.Query <Category_model>(sql, new { id = ID }).SingleOrDefault(); } } catch (Exception) { returnCode = (int)Common.ReturnCode.UnSuccess; } return(returnCode); }
private async void makeGetCategoryRequest() { try { using (var client = new HttpClient()) { var getDataUrl = new System.Uri(BaseURL.Categories); var result = await client.GetStringAsync(getDataUrl); var response = JsonConvert.DeserializeObject <ResultArray>(result); string status = response.status; if (status == "200") { var jsonArray = response.data; if (jsonArray.Count() > 0) { for (int i = 0; i < jsonArray.Count(); i++) { Category_model category_Model = new Category_model(); if (jsonArray[i].level.ToLower() == "yes" && jsonArray[i].IsStorePublished) { category_Model.cat_id = jsonArray[i].GroupMastID.ToString(); category_Model.title = jsonArray[i].ItemCategory.ToString(); category_Model.image = jsonArray[i].m_ParentItemImageURL.ToString(); category_modelList.Add(category_Model); } } } adapter = new Home_adapter(category_modelList, Context); rv_items.SetAdapter(adapter); adapter.NotifyDataSetChanged(); } } } catch (Exception ex) { } }
public int Update(Category_model model, out List <string> lstMsg) { int result = (int)Common.ReturnCode.Succeed; lstMsg = new List <string>(); try { if (isError(model, (int)Common.ActionType.Update, out lstMsg)) { return((int)Common.ReturnCode.UnSuccess); } string sql = "UPDATE `product_category` SET `parent_id` = @parent_id, `code` = @code, `name` = @name, `description` = @description, `updated_datetime` = '" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.FFFFFF") + "' WHERE `id` = @id "; db.Execute(sql, model); } catch (Exception ex) { lstMsg.Add("Exception Occurred."); result = (int)Common.ReturnCode.UnSuccess; } return(result); }
public ActionResult Edit(string id) { if (string.IsNullOrEmpty(id)) { TempData["Error"] = "Data has already been deleted by other user!"; return(RedirectToAction("Index")); } Category_model Model = new Category_model(); int returnCode = _categoryBL.GetByID(long.Parse(id), out Model); if (Model == null) { TempData["Error"] = "Data has already been deleted by other user!"; return(RedirectToAction("Index")); } if (!((int)Common.ReturnCode.Succeed == returnCode)) { Model = new Category_model(); } ViewBag.Parent = new SelectList(_categoryBL.GetListParent(), "id", "name"); return(View(Model)); }
public bool isError(Category_model Model, int action, out List <string> lstMessgae) { bool flag = false; lstMessgae = new List <string>(); if ((int)Common.ActionType.Add == action) { string sql = "SELECT * FROM `product_category` WHERE `code` = @code"; var result = db.Query <Category_model>(sql, new { code = Model.code.Trim() }).ToList(); if (result.Count != 0) { flag = true; lstMessgae.Add("[Code] is duplicate!"); } } if ((int)Common.ActionType.Update == action) { string sql = "SELECT * FROM `product_category` WHERE `code` = @code AND `id` <> @id"; var result = db.Query <Category_model>(sql, new { code = Model.code.Trim(), id = Model.id }).ToList(); if (result.Count != 0) { flag = true; lstMessgae.Add("[Code] is duplicate!"); } } if ((int)Common.ActionType.Delete == action) { string sql = "SELECT `id` FROM `product_category` WHERE `id` = @id"; var hasItem = db.Query <CategoryParent_model>(sql, new { code = Model.code.Trim() }).ToList(); if (hasItem.Count == 0) { flag = true; lstMessgae.Add("[Category] is not found!"); } } return(flag); }
public int Update(Category_model model, out List <string> lstMsg) { return(category_bll.Update(model, out lstMsg)); }
public int Insert(Category_model model, out List <string> lstMsg) { return(category_bll.Insert(model, out lstMsg)); }
public int GetByID(long ID, out Category_model model) { return(category_bll.GetByID(ID, out model)); }