Пример #1
0
		private List<SelectListItem> GetDirections()
		{
			var directions = _mapper.Map<IEnumerable<DirectionDTO>, List<DirectionViewModel>>(_directionService.GetDirections());
			List<SelectListItem> selectItems = new List<SelectListItem>();

			foreach (var item in directions)
			{
				selectItems.Add(new SelectListItem { Text = item.Name, Value = item.DirectionId.ToString() });
			}

			return selectItems;
		}
        public IHttpActionResult PostDirection(IEnumerable <DirectionModel> directionModels)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var directions = new List <Direction>();

            directions = ObjectFactory.Parse(directionModels, directions).ToList();

            _directionService.AddList(directions);

            db.SaveChanges();

            var newDirections       = _directionService.GetDirections(directions);
            var newDirectionsModels = ModelFactory.Create(newDirections);

            return(Ok(newDirectionsModels));
        }
Пример #3
0
        private List <SelectListItem> GetDirections()
        {
            //get Directions for DropDownList
            var directions = Mapper.Map <IEnumerable <DirectionTransferModel>, List <DirectionViewModel> >(_directionService.GetDirections());
            List <SelectListItem> selectItems = new List <SelectListItem>();

            foreach (var item in directions)
            {
                selectItems.Add(new SelectListItem {
                    Text = item.Name, Value = item.DirectionId.ToString()
                });
            }
            return(selectItems);
        }