public IEnumerable <TradeGroup> Get() { List <TradeGroup> tradeGroups = new List <TradeGroup>(); using (SqlDataReader reader = SqlHelper.ExecuteReader("Select * From [dbo].[tblTradeGroup]", CommandType.Text)) { while (reader.Read()) { TradeGroup tradeGroup = new TradeGroup(); tradeGroup.Id = int.Parse(reader["tradeGroupId"].ToString()); tradeGroup.Name = reader["tradeGroupName"].ToString(); tradeGroups.Add(tradeGroup); } } return(tradeGroups); }
public ActionResult EditTradeGroup(TradeGroup tradeGroup) { try { //////// validation if (!Utilities.IsRequiredStringInputsValid(tradeGroup.Name)) { return(RedirectToAction("Error", "Home", new { message = "فیلدهای ستاره دار را بدرستی وارد کنید" })); } tradeGroup.Status = "فعال"; tradeGroup.Name = tradeGroup.Name.ToFarsiString().Trim(); ////////////// if (ModelState.IsValid) { string message = ""; if (blTradeGroup.Update(tradeGroup, out message)) { return(RedirectToAction("Groups", "GroupAndColor")); } else { if (message.Contains("TradeGroups(Name Must Unique)")) { return(RedirectToAction("Error", "Home", new { message = "نام گروه صنف باید یکتا باشد" })); } return(RedirectToAction("Error", "Home", new { message = "خطا رخ داده است. مجددا تلاش کنید" })); } } else { return(RedirectToAction("Error", "Home", new { message = "خطا رخ داده است. مجددا تلاش کنید" })); } } catch { return(RedirectToAction("Error", "Home", new { message = "خطا رخ داده است. مجددا تلاش کنید" })); } }
public ActionResult AddTradeGroup() { var model = new TradeGroup(); return(View(model)); }