public bool Insert(TrainingProduct entity) { bool ret = false; ret = Validate(entity); if (ret) { //TODO: Create INSERT code here } return ret; }
// UPDATE Method to database public bool Update(TrainingProduct entity) { bool ret = false; ret = Validate(entity); if (ret) { // TODO: Create UPDATE Code here } return ret; }
public TrainingProduct Get(int ProductId) { List<TrainingProduct> list = new List<TrainingProduct>(); TrainingProduct ret = new TrainingProduct(); // TODO: Call your data access method here list = CreateMockData(); ret = list.Find(p => p.ProductId == ProductId); return ret; }
public List<TrainingProduct> Get(TrainingProduct entity) { List<TrainingProduct> ret = new List<TrainingProduct>(); // TODO: Add your data access method here. ret = CreateMockData(); if (!string.IsNullOrEmpty(entity.ProductName)) { ret = ret.FindAll(p => p.ProductName.ToLower().StartsWith(entity.ProductName, StringComparison.CurrentCultureIgnoreCase)); } return ret; }
public bool Validate(TrainingProduct entity) { ValidationErrors.Clear(); if (!string.IsNullOrEmpty(entity.ProductName)) { // Check for lower case if (entity.ProductName.ToLower() == entity.ProductName) { ValidationErrors.Add(new KeyValuePair<string, string>("ProductName", "Product Name must not be all lowe case.")); // Business Rule failed. } } return (ValidationErrors.Count == 0); // return True or False }
// I could have simply passed the ProductId here but I kinda like passing the whole entity public bool Delete(TrainingProduct entity) { //TODO: Create DELETE code here return true; }
protected override void Add() { IsValid = true; Entity = new TrainingProduct(); Entity.IntroductionDate = DateTime.Now; Entity.Url = "http://"; Entity.Price = 0; AddMode(); }
protected override void ResetSearch() { SearchEntity = new TrainingProduct(); }
protected override void Init() { Products = new List<TrainingProduct>(); SearchEntity = new TrainingProduct(); Entity = new TrainingProduct(); base.Init(); }
protected override void Delete() { TrainingProductManager mgr = new TrainingProductManager(); Entity = new TrainingProduct(); Entity.ProductId = Convert.ToInt32(EventArgument); mgr.Delete(Entity); Get(); ListMode(); }