/// <summary> /// This is to get all the todo's items /// Here we have used automapper to convert the DAL model list to domain model list /// </summary> /// <returns>This will retun a list of todo's items as list</returns> public List <Domain.Models.ToDoItem> GetAll() { List <Domain.Models.ToDoItem> items = new List <Domain.Models.ToDoItem>(); var itemsDAL = _repository.All().ToList(); if (null != itemsDAL & itemsDAL.Count > 0) { //This is to initilize the automapper Mapper.Initialize(cfg => cfg.CreateMap <DataAccessLayer.Models.ToDoItem, Domain.Models.ToDoItem>()); //This is convert the DAL model list to Domain model list, this will take DAL model list as parameter and return Domain model list as response items = Mapper.Map <List <DataAccessLayer.Models.ToDoItem>, List <Domain.Models.ToDoItem> >(itemsDAL); } return(items); }
/// <summary> /// This is to get all the todo's items /// Here we have used automapper to convert the DAL model list to domain model list /// </summary> /// <returns>This will retun a list of todo's items as list</returns> public List <Domain.Models.ToDoItem> GetAll() { Console.WriteLine("Get call start"); try { List <Domain.Models.ToDoItem> items = new List <Domain.Models.ToDoItem>(); var itemsDAL = _repository.All().ToList(); if (null != itemsDAL & itemsDAL.Count > 0) { //This is to initilize the automapper Mapper.Initialize(cfg => cfg.CreateMap <DataAccessLayer.Models.ToDoItem, Domain.Models.ToDoItem>()); //This is convert the DAL model list to Domain model list, this will take DAL model list as parameter and return Domain model list as response items = Mapper.Map <List <DataAccessLayer.Models.ToDoItem>, List <Domain.Models.ToDoItem> >(itemsDAL); } return(items); } catch (Exception ex) { Console.WriteLine("Get call ex :" + ex.Message); return(null); } }