Exemplo n.º 1
0
        public bool Save(SaveTopicInputDto inputDTO)
        {
            Topic topic = this.topicRepository.FindBy(x => x.ID == inputDTO.ID).FirstOrDefault();

            if (topic == null)
            {
                topic    = new Topic();
                topic.ID = this.topicRepository.GetAll().OrderByDescending(item => item.ID).FirstOrDefault().ID + 1;
            }

            topic.Name        = inputDTO.Name;
            topic.DisplayName = inputDTO.DisplayName;
            topic.Description = inputDTO.Description;

            if (inputDTO.ID == 0)
            {
                this.topicRepository.Add(topic);
            }
            else
            {
                this.topicRepository.Update(topic);
            }

            this.unitOfWork.Commit();

            return(true);
        }
Exemplo n.º 2
0
        public HttpResponseMessage SaveTopic(HttpRequestMessage request, SaveTopicInputDto inputDTO)
        {
            return(CreateHttpResponse(request, () =>
            {
                var result = this.topicService.Save(inputDTO);

                response = request.CreateResponse(HttpStatusCode.OK, new { result });

                return response;
            }));
        }