public RestAPIUpdateIdeaResponse UpdateDetails(RestAPIUpdateIdeaRequest req, [FromUri] int IdeaId)
        {
            RestAPIUpdateIdeaResponse response = new RestAPIUpdateIdeaResponse();

            submitIdeaUtil.UpdateIdea(response, UserID, IdeaId, req);
            logUtil.InsertIdeaLog(response, IdeaId, LogMessages.UpdateDetails, (int)IdeaLogTypes.Info, Enum.GetName(typeof(IdeaMethodTypes), IdeaMethodTypes.UpdateDetails), EnumDescriptor.GetEnumDescription(IdeaMethodTypes.UpdateDetails), UserID);

            return(response);
        }
Example #2
0
        public void UpdateIdeaTest()
        {
            RestAPIUpdateIdeaResponse response = new RestAPIUpdateIdeaResponse();
            RestAPIUpdateIdeaRequest  request  = new RestAPIUpdateIdeaRequest()
            {
                Title       = "test",
                Description = "demo"
            };
            Idea idea   = new Idea();
            int  UserId = 1;
            int  IdeaId = 1;

            queryUtilMock.Setup(x => x.GetIdeaById(It.IsAny <IIdeaDatabaseDataContext>(), It.IsAny <int>())).Returns(idea);
            submitIdeaMock.Setup(x => x.UpdateIdea(It.IsAny <RestAPIUpdateIdeaResponse>(), It.IsAny <int>(), It.IsAny <int>(), It.IsAny <RestAPIUpdateIdeaRequest>()));
            submitIdeaUtil.UpdateIdea(response, UserId, IdeaId, request);

            Assert.IsTrue(response.ErrorList.Count == 0);
        }
        public void UpdateIdea(RestAPIUpdateIdeaResponse response, int UserID, int IdeaId, RestAPIUpdateIdeaRequest request)
        {
            DatabaseWrapper.databaseOperation(response,
                                              (context, query) =>
            {
                Idea idea = query.GetIdeaById(context, IdeaId);
                if (idea != null)
                {
                    if (!string.IsNullOrEmpty(request.GitRepo))
                    {
                        idea.GitRepo = request.GitRepo;
                    }
                    else
                    {
                        idea.GitRepo = null;
                    }
                    if (!string.IsNullOrEmpty(request.Title))
                    {
                        idea.Title = request.Title;
                    }
                    if (!string.IsNullOrEmpty(request.Description))
                    {
                        idea.Description = request.Description;
                    }
                    if (!string.IsNullOrEmpty(request.BusinessImpact))
                    {
                        idea.BusinessImpact = request.BusinessImpact;
                    }
                    if (!string.IsNullOrEmpty(request.Solution))
                    {
                        idea.Solution = request.Solution;
                    }
                    if (request.ChallengeId.GetValueOrDefault(0) != 0)
                    {
                        idea.ChallengeId = request.ChallengeId;
                    }
                    if (request.CategoryId.GetValueOrDefault(0) != 0)
                    {
                        idea.CategoryId = request.CategoryId;
                    }
                    if (!string.IsNullOrWhiteSpace(request.Tags))
                    {
                        tagUtil.InsertTags(response, idea, request.Tags, UserID);
                    }
                    else
                    {
                        query.DeleteIdeaTags(context, IdeaId);
                    }
                }
                else
                {
                    response.ErrorList.Add(Faults.IdeaNotFound);
                    response.Status = Failure;
                    return;
                }

                response.Status   = Success;
                idea.ModifiedDate = DateTime.UtcNow;

                context.SubmitChanges();
            }
                                              , readOnly: false
                                              );

            if (response == null && response.ErrorList.Count != 0)
            {
                response.ErrorList.Add(Faults.ServerIsBusy);
            }
        }