コード例 #1
0
        public void Create(News news)
        {
            try
            {
                var mapNews = AutoMapper.Mapper.Map
                    <Data.Entities.News>(news);

                _newsRepository.Add(mapNews);

                _unitOfWork.Commit();
            }
            catch (Exception exception)
            {
                throw new FaultException(exception.Message);
            }
        }
コード例 #2
0
        public void Update(News news)
        {
            try
            {
                var mapNews = AutoMapper.Mapper.Map
                    <Data.Entities.News>(news);

                var actualNews = _newsRepository
                    .FindBy(n => n.Id == mapNews.Id)
                    .First();

                actualNews.EmployeeId = mapNews.EmployeeId;
                actualNews.Content = mapNews.Content;
                actualNews.Title = mapNews.Title;
                actualNews.CreateDate = DateTime.Now;

                _unitOfWork.Commit();
            }
            catch (Exception exception)
            {
                throw new FaultException(exception.Message);
            }
        }