Пример #1
0
        public async Task <HttpResponseMessage> AddCommentToState(FileStateCommentRequest request)
        {
            IResultServiceModel <FileStateCommentResponse> response = new ResultServiceModel <FileStateCommentResponse>();

            try
            {
                var rmCredentials = this.ValidateUserCredentials(request.userName);
                if (rmCredentials.Success)
                {
                    response = await this.mainService.AddCommentToFileStateAsync(request);
                }
                else
                {
                    response.OnError(rmCredentials);
                }
            }
            catch (Exception ex)
            {
                response.OnException(ex);
            }

            string uri          = Url.Link("FileAddCommentToStateApi", new { id = request.id });
            var    httpResponse = Request.CreateResponse <IResultServiceModel <FileStateCommentResponse> >(HttpStatusCode.Created, response);

            httpResponse.Headers.Location = new Uri(uri);

            return(httpResponse);
        }
Пример #2
0
        public IResultServiceModel <FileStateCommentResponse> AddCommentToFileState(FileStateCommentRequest request, User user)
        {
            IResultServiceModel <FileStateCommentResponse> rsm = new ResultServiceModel <FileStateCommentResponse>();

            try
            {
                var stateNote = new WFFileStateNote()
                {
                    TS              = request.ts,
                    Comment         = request.comment,
                    UserId          = user.Id,
                    WFEntityStateId = request.stateId
                };

                this.wfFileStateNoteRepository.Add(stateNote);
                var rm = this.wfFileStateNoteRepository.Save();
                if (rm.Success)
                {
                    rsm.OnSuccess(new FileStateCommentResponse()
                    {
                        fileId     = request.fileId,
                        stateId    = request.stateId,
                        newId      = stateNote.Id,
                        temporalId = request.id
                    });
                }
                else
                {
                    rsm.OnError(rm);
                }
            }
            catch (Exception ex)
            {
                rsm.OnException(ex);
            }

            return(rsm);
        }