コード例 #1
0
        public JsonResult SaveEvent(string jsonEvent, long questId)
        {
            var frontEvent = SerializeHelper.Deserialize<FrontEvent>(jsonEvent);
            var eventModel = frontEvent.ToDbModel();

            var linksFromThisEvent = eventModel.LinksFromThisEvent;
            foreach (var eventLinkItem in linksFromThisEvent)
            {
                EventLinkItemRepository.Save(eventLinkItem);
            }
            var linksToThisEvent = eventModel.LinksToThisEvent;
            foreach (var eventLinkItem in linksToThisEvent)
            {
                EventLinkItemRepository.Save(eventLinkItem);
            }

            if (eventModel.Id == 0)
            {
                eventModel.Quest = QuestRepository.Get(questId);
            }

            var eventFromDb = EventRepository.Save(eventModel);
            var frontEvents = new FrontEvent(eventFromDb);
            return new JsonResult
            {
                Data = JsonConvert.SerializeObject(frontEvents),
                JsonRequestBehavior = JsonRequestBehavior.AllowGet
            };
        }
コード例 #2
0
 public JsonResult GetEvent(long id)
 {
     var eventFromDb = EventRepository.Get(id);
     var frontEvent = new FrontEvent(eventFromDb);
     return new JsonResult
     {
         Data = JsonConvert.SerializeObject(frontEvent),
         JsonRequestBehavior = JsonRequestBehavior.AllowGet
     };
 }