Exemplo n.º 1
0
        public void UpdateAll(List <Position> positionsFetched)
        {
            var positions = _repository.GetAll();

            // Delete should be cascade if it's necessary
            // foreach (var position in positions)
            // {
            //     if (!positionsFetched.Select(v => v.Id).Contains(position.Id))
            //         _repository.Delete(position);
            // }
            foreach (var positionFetched in positionsFetched)
            {
                var foundPosition = positions.SingleOrDefault(v => v.Id == positionFetched.Id);
                if (foundPosition == null)
                {
                    _repository.Add(positionFetched);
                }
                else
                {
                    var name = positionFetched.Name.Trim();
                    if (foundPosition.Name != name)
                    {
                        foundPosition.Name = name;
                        _repository.Update(foundPosition);
                    }
                }
            }
        }
Exemplo n.º 2
0
        public void Update(
            int id,
            PositionRequest position)
        {
            if (position == null)
            {
                throw new ArgumentNullException(nameof(position));
            }
            var foundposition = _repository.GetById(id);

            if (foundposition == null)
            {
                throw new ArgumentNullException(nameof(foundposition));
            }

            foundposition.ShortName = position.ShortName;
            foundposition.LongName  = position.LongName;
            _repository.Update(foundposition);
        }
Exemplo n.º 3
0
 public void Put(Position position)
 {
     _positionRepo.Update(position);
 }