protected override void init()
        {
            base.init();

            Products     = new List <TrainingProduct>();
            SearchEntity = new TrainingProduct();
            Entity       = new TrainingProduct();
        }
Ejemplo n.º 2
0
        //Edit Mode - to get single record based on ProductID
        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);
        }
        protected override void Add()
        {
            IsValid = true;
            Entity  = new TrainingProduct();
            Entity.Introductiondate = DateTime.Now;
            Entity.Url   = "http://";
            Entity.Price = 0;

            base.Add();
        }
Ejemplo n.º 4
0
        //Save Mode: Insert data after validation
        public bool Insert(TrainingProduct Entity)
        {
            bool ret = false;

            ret = Validate(Entity);
            if (ret)
            {
                //Create Insert code here
            }
            return(ret);
        }
Ejemplo n.º 5
0
        //Update Mode
        public bool Update(TrainingProduct entity)
        {
            bool ret = false;

            ret = Validate(entity);
            if (ret)
            {
                //TODO: write Update code here...
            }
            return(ret);
        }
        protected override void Delete()
        {
            TrainingProductManager mgr = new TrainingProductManager();

            Entity           = new TrainingProduct();
            Entity.ProductID = Convert.ToInt32(EventArgument);
            mgr.Delete(Entity);

            Get();
            base.Delete();
        }
        protected override void Edit()
        {
            TrainingProductManager mgr = new TrainingProductManager();

            //Entity holds the current ProductID
            Entity = mgr.Get(Convert.ToInt32(EventArgument));
            // Entity = mgr.Get(Convert.ToInt32("6"));

            //Set to Edit view Mode
            base.Edit();
        }
Ejemplo n.º 8
0
 //Adding Extra validations on ProductName (otherthan Data annotations)
 public Boolean Validate(TrainingProduct entity)
 {
     ValidationErrors.Clear();
     if (!String.IsNullOrEmpty(entity.ProductName))
     {
         if (entity.ProductName.ToLower() == entity.ProductName)
         {
             ValidationErrors.Add(new KeyValuePair <string, string>("ProductName", "Productname must not be all lower case."));
         }
     }
     return(ValidationErrors.Count == 0);
 }
Ejemplo n.º 9
0
        //Search Mode: Search for a given product name
        public List <TrainingProduct> Get(TrainingProduct entity)
        {
            List <TrainingProduct> ret = new List <TrainingProduct>();

            ret = CreateMockData();
            if (!string.IsNullOrEmpty(entity.ProductName))
            {
                //This area filters the class - Search
                ret = ret.FindAll(p => p.ProductName.ToLower().StartsWith(entity.ProductName, StringComparison.CurrentCultureIgnoreCase));
                //ret = ret.FindAll(p => p.ProductName.StartsWith(entity.ProductName));
            }
            return(ret);
        }
Ejemplo n.º 10
0
 public bool Delete(TrainingProduct entity)
 {
     //TODO : Delete code for DB
     return(true);
 }
 protected override void ResetSearch()
 {
     SearchEntity = new TrainingProduct();
     base.ResetSearch();
 }