private void FillLoggedModel(ActivityLog log, ActivityLoggedModelDetailsViewModel result)
        {
            var loggedModels = _repositoryLoggedModel.Find(x => x.LogId == log.Id).ToList();

            foreach (var model in loggedModels)
            {
                result.ModelDetails = CreateActivityViewModel(model.Model, log.ModelName);
            }
        }
        private void FillLoggedCollectionModel(ObjectId logId, ActivityLoggedModelDetailsViewModel result)
        {
            var loggedModels = _repositoryLoggedCollectionModel.Find(x => x.LogId == logId).ToList();

            var collectionModels = new List <ActivityLoggedModelViewModel>();

            foreach (var model in loggedModels)
            {
                var item = CreateActivityViewModel(model.Model, model.ModelName);
                collectionModels.Add(item);
            }

            result.Collections = collectionModels;
        }
Example #3
0
        public virtual ActionResult LoggedModelDetails(string logId)
        {
            var model = new ActivityLoggedModelDetailsViewModel();

            try
            {
                model = _activityLogViewService.GetModelDetails(logId);
            }
            catch (Exception e)
            {
                _logger.Error(e);
                model.FeedbackMessage = FeedbackMessageModel.CreateFailureMessage("Some Error Occured");
            }
            return(View(model));
        }
        private bool ProcessExceptionModel(ActivityLog activityLog, ActivityLoggedModelDetailsViewModel result)
        {
            var isProcessed = false;

            switch (activityLog.ModelName)
            {
            case "AdminEditModel":
            {
                isProcessed = true;
                ProcessAdminEditModel(activityLog, result);
                break;
            }
            }
            return(isProcessed);
        }
        public ActivityLoggedModelDetailsViewModel GetModelDetails(string logId)
        {
            var id     = new ObjectId(logId);
            var result = new ActivityLoggedModelDetailsViewModel();

            var activityLog = _repositoryActivityLog.Find(x => x.Id == id).First();

            if (ProcessExceptionModel(activityLog, result))
            {
                return(result);
            }

            FillLoggedModel(activityLog, result);

            FillLoggedCollectionModel(id, result);

            result.ActivityLog = _activityLogFactory.CreateViewModel(activityLog);
            return(result);
        }
        private void ProcessAdminEditModel(ActivityLog activityLog, ActivityLoggedModelDetailsViewModel result)
        {
            var modelName         = "AdminEditModel";
            var adminEditModelDoc = _repositoryLoggedModel.Find(x => x.LogId == activityLog.Id).First();
            var newDoc            = new BsonDocument();
            var user = adminEditModelDoc.Model["User"];

            if (user != null && user.IsBsonDocument)
            {
                var doc           = (BsonDocument)user;
                var personDetails = (BsonDocument)doc["PersonEditModel"];
                newDoc.Add(personDetails.Elements);
                var userLoginDetails = (BsonDocument)doc["UserLogin"];
                newDoc.Add(userLoginDetails.Elements);
            }
            newDoc.Add(new BsonElement("IsAccountAdmin", adminEditModelDoc.Model["IsAccountAdmin"]));
            newDoc.Add(new BsonElement("AccountId", adminEditModelDoc.Model["AccountId"]));


            result.ModelDetails = CreateActivityViewModel(newDoc, modelName);
        }