public ActionResult List(Enum_Price_MasterType type, long id) { List <Price> c = new List <Price>(); c = Db.Where <Price>(x => x.MasterType == type && x.MasterId == id); var list_users = Cache_GetAllUsers(); foreach (var x in c) { var z = list_users.Where(m => m.Id == x.CreatedBy); if (z.Count() > 0) { var k = z.First(); if (string.IsNullOrEmpty(k.FullName)) { x.CreatedByUsername = k.UserName; } else { x.CreatedByUsername = k.FullName; } } else { x.CreatedByUsername = "******"; } } Db.Close(); return(PartialView("_List", c)); }
public Price getPrice(Enum_Price_MasterType type = Enum_Price_MasterType.ProductOption, string countrycode = "MY") { var price = base.getPrice(Id, type, countrycode); Price ret = null; if (price.Count > 0) { if (string.IsNullOrEmpty(countrycode)) { // find RM, Malaysia ret = price.Where(x => x.CountryCode == "MY").FirstOrDefault(); if (ret == null) { ret = price.FirstOrDefault(); } } else { ret = price.FirstOrDefault(); } } else { ret = new Price(); } Db.Close(); return(ret); }
public Price getPrice(Enum_Price_MasterType type, string countrycode) { if (string.IsNullOrEmpty(countrycode)) { countrycode = "MY"; } countrycode = countrycode.ToUpper().Trim(); var price = base.getPrice(this.Id, type, countrycode); Price ret = null; if (price.Count > 0) { if (string.IsNullOrEmpty(countrycode)) { // find RM, Malaysia ret = price.Where(x => x.CountryCode == "MY").FirstOrDefault(); if (ret == null) { ret = price.FirstOrDefault(); } } else { ret = price.FirstOrDefault(); } } else { ret = new Price(); } Db.Close(); return(ret); }
/// <summary> /// Get the price object according to the price_id /// For internal use. /// In each of your class, you have to implement it again your self /// </summary> /// <param name="price_id"></param> /// <returns></returns> protected List <Price> getPrice(long master_id, Enum_Price_MasterType type, string countrycode = "") { countrycode = countrycode.ToUpper().Trim(); if (string.IsNullOrEmpty(countrycode)) { return(Db.Select <Price>(x => x.Where(m => m.MasterType == type && m.MasterId == master_id))); } else { return(Db.Select <Price>(x => x.Where(m => m.MasterType == type && m.MasterId == master_id && m.CountryCode == countrycode))); } }
public ActionResult Add(Enum_Price_MasterType type, long m_id) { Price model = new Price(); model.Master_Name = getMasterObjectName(type, m_id); if (string.IsNullOrEmpty(model.Master_Name)) { return(Redirect("/")); } model.MasterId = m_id; model.MasterType = type; return(View(model)); }
/// <summary> /// List the price /// </summary> /// <param name="type"></param> /// <param name="id"></param> /// <param name="?"></param> /// <returns></returns> public ActionResult Index(Enum_Price_MasterType type, long id) { string name = getMasterObjectName(type, id); if (string.IsNullOrEmpty(name)) { // there is no master object prepresented by id return(Redirect("/")); } ViewData["type"] = type; ViewData["id"] = id; ViewData["name"] = name; Db.Close(); return(View()); }
/// <summary> /// Get Master Object Name /// </summary> /// <param name="type"></param> /// <param name="id"></param> /// <returns></returns> string getMasterObjectName(Enum_Price_MasterType type, long id) { var name = ""; switch (type) { case Enum_Price_MasterType.ProductOption: var po = Db.Select <Product_Option>(x => x.Where(m => m.Id == id).Limit(1)).FirstOrDefault(); if (po == null) { name = ""; } else { name = po.Name; } break; case Enum_Price_MasterType.Product: case Enum_Price_MasterType.ProductShippingPrice: var pp = Db.Select <Product>(x => x.Where(m => m.Id == id).Limit(1)).FirstOrDefault(); if (pp != null) { name = pp.Name; // try to get the category also var cat = Db.Select <Product_Category>(x => x.Where(m => m.Id == pp.CatId).Limit(1)).FirstOrDefault(); if (cat != null) { name += " / " + cat.Name; } } break; default: name = ""; break; } return(name); }