/// <summary>
 /// 
 /// </summary>
 /// <param name="creditComment"></param>
 private void UpdateCreditProcessFlowComment(CreditComment creditComment)
 {
     _creditProcessesRepository.UpdateCreditProcessFlowComment(creditComment);
 }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="creditComment"></param>
 private void AddCreditProcessFlowComment(CreditComment creditComment)
 {
     _creditProcessesRepository.AddCreditProcessFlowComment(creditComment);
 }
        private static CreditComment Map(CommentViewModel viewModel)
        {
            var creditComment = new CreditComment
                                {
                                    CreditCommentId = viewModel.Id,
                                    CreditProcessId = viewModel.CreditProcessId,
                                    creditProcessXCompanyId = viewModel.CreditProcessXCompanyId,
                                    Comment = viewModel.Comment,
                                    CommentDate = viewModel.CommentDate,
                                };

            return creditComment;
        }
        public void AddCreditProcessFlowComment(CreditComment creditProcessFlowComment)
        {
            _databaseModel.CreditComments.Add(creditProcessFlowComment);

            _databaseModel.SaveChanges();
        }
        public void UpdateCreditProcessFlowComment(CreditComment creditProcessFlowComment)
        {
            var entry = _databaseModel.Entry(creditProcessFlowComment);
            if (entry.State == EntityState.Detached)
            {
                var set = _databaseModel.Set<CreditProcessXCompany>();
                var attachedEntity = set.Find(creditProcessFlowComment.CreditCommentId);  // You need to have access to key

                if (attachedEntity != null)
                {
                    var attachedEntry = _databaseModel.Entry(attachedEntity);
                    attachedEntry.CurrentValues.SetValues(creditProcessFlowComment);
                }
                else
                {
                    entry.State = EntityState.Modified; // This should attach entity
                }
            }

            _databaseModel.SaveChanges();
        }
        private CommentViewModel Map(CreditComment creditComment)
        {
            var viewModel = new CommentViewModel
                            {
                                Id = creditComment.CreditCommentId,
                                Comment = creditComment.Comment,
                                CommentDate = creditComment.CommentDate,
                                CreditProcessId = creditComment.CreditProcessId,
                                IsNew = false,
                            };

            return viewModel;
        }