Exemplo n.º 1
0
 public HistoryEventInfo Save([FromBody] HistoryEventInfo value)
 {
     if (value != null && ModelState.IsValid)
     {
         return(HistoryEventService.Save(value));
     }
     else
     {
         throw new CustomerApiException(HttpStatusCode.NotAcceptable, 1, "字段值不合法");
     }
 }
Exemplo n.º 2
0
 public void Update(int id, [FromBody] HistoryEventInfo value)
 {
     if (value != null && ModelState.IsValid)
     {
         value.HistoryEventId = id;
         HistoryEventService.Update(value);
         //不处理图片文件了
     }
     else
     {
         throw new CustomerApiException(HttpStatusCode.NotAcceptable, 1, "字段值不合法");
     }
 }
        public void Update(HistoryEventInfo historyEventInfo)
        {
            historyEventRepository.Update(HistoryEventConverter.ConvertToDo(historyEventInfo), p => p.HistoryEventId);
            personEventRelationRepository.DeleteByLinq(p => p.HistoryEventId == historyEventInfo.HistoryEventId);
            var personIds = historyEventInfo.PersonIds;

            foreach (var personId in personIds)
            {
                personEventRelationRepository.Save(new PersonEventRelation()
                {
                    HistoryEventId = historyEventInfo.HistoryEventId,
                    FamousPersonId = personId
                });
            }
        }
        public HistoryEventInfo Save(HistoryEventInfo historyEventInfo)
        {
            var @event    = historyEventRepository.Save(HistoryEventConverter.ConvertToDo(historyEventInfo));
            var personIds = historyEventInfo.PersonIds;

            foreach (var personId in personIds)
            {
                personEventRelationRepository.Save(new PersonEventRelation()
                {
                    HistoryEventId = @event.HistoryEventId,
                    FamousPersonId = personId
                });
            }
            historyEventInfo.HistoryEventId = @event.HistoryEventId;
            return(historyEventInfo);
        }
        public static HistoryEvent ConvertToDo(HistoryEventInfo historyEventInfo)
        {
            if (historyEventInfo == null)
            {
                return(null);
            }
            var history = new HistoryEvent()
            {
                Detail         = historyEventInfo.Detail,
                HistoryEventId = historyEventInfo.HistoryEventId,
                OccurDate      = historyEventInfo.OccurDate,
                OccurX         = historyEventInfo.OccurX,
                OccurY         = historyEventInfo.OccurY,
                Place          = historyEventInfo.Place,
                Province       = historyEventInfo.Province,
                Title          = historyEventInfo.Title
            };

            return(history);
        }
        public static HistoryEventInfo ConvertToDto(HistoryEvent historyEvent, IEnumerable <Int32> personIds)
        {
            if (historyEvent == null)
            {
                return(null);
            }
            var historyInfo = new HistoryEventInfo()
            {
                Detail         = historyEvent.Detail,
                HistoryEventId = historyEvent.HistoryEventId,
                OccurDate      = historyEvent.OccurDate,
                OccurX         = historyEvent.OccurX,
                OccurY         = historyEvent.OccurY,
                Place          = historyEvent.Place,
                Province       = historyEvent.Province,
                Title          = historyEvent.Title,
                PersonIds      = personIds
            };

            return(historyInfo);
        }