示例#1
0
        public bool Save(SaveTutorialContentInputDto inputDTO)
        {
            TutorialContent tt = this.tutorialContentRepository.FindBy(x => x.ID == inputDTO.ID).FirstOrDefault();

            if (tt == null)
            {
                tt = new TutorialContent();
            }

            tt.ParentID          = inputDTO.ParentID;
            tt.Description       = Cmn.GetCompressed(inputDTO.Description);
            tt.DescriptionLength = inputDTO.Description.Length;
            tt.Title             = inputDTO.Title;
            tt.Type = inputDTO.Type;
            tt.Seq  = inputDTO.Seq;

            if (inputDTO.ID == 0)
            {
                this.tutorialContentRepository.Add(tt);
            }
            else
            {
                this.tutorialContentRepository.Update(tt);
            }

            this.unitOfWork.Commit();

            return(true);
        }
        public HttpResponseMessage SaveTutorialContent(HttpRequestMessage request, SaveTutorialContentInputDto inputDTO)
        {
            return(CreateHttpResponse(request, () =>
            {
                var result = this.tutorialContentService.Save(inputDTO);

                if (result)
                {
                    response = request.CreateResponse(HttpStatusCode.OK, new { result });
                }
                else
                {
                    response = request.CreateErrorResponse(HttpStatusCode.NotFound, string.Empty);
                }

                return response;
            }));
        }