Beispiel #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="userName"></param>
        /// <param name="currentUserName"></param>
        /// <param name="appID"></param>
        /// <param name="overrideID"></param>
        /// <param name="code"></param>
        /// <param name="dataRepository"></param>
        /// <param name="uow"></param>
        /// <returns></returns>
        public CommandVMDC GetCommand(string userName, string currentUserName, string appID, string overrideID, string code, IUnitOfWork uow, IRepository <Command> dataRepository
                                      )

        {
            try
            {
                using (uow)
                {
                    // Convert code to Guid
                    Guid codeGuid = Guid.Parse(code);

                    // Retrieve specific Command
                    Command dataEntity = dataRepository.Single(x => x.Code == codeGuid);

                    // Convert to data contract for passing through service interface
                    CommandDC destination = Mapper.Map <Command, CommandDC>(dataEntity);



                    // Create aggregate contract
                    CommandVMDC message = new CommandVMDC();

                    message.CommandItem = destination;

                    return(message);
                }
            }
            catch (Exception e)
            {
                //Prevent exception from propogating across the service interface
                ExceptionManager.ShieldException(e);

                return(null);
            }
        }
Beispiel #2
0
        //This method is shared between create and save
        private ActionResult UpdateCommand()
        {
            var model = GetUpdatedModel();

            var errors = ModelState
                         .Where(x => x.Value.Errors.Count > 0)
                         .Select(x => new { x.Key, x.Value.Errors[0].ErrorMessage })
                         .ToArray();

            //Set flags false
            SetFlagsFalse(model);
            if (ModelState.IsValid)
            {
                //Attempt update
                try
                {
                    AdminServiceClient sc = new AdminServiceClient();
                    CommandDC          CommandToCreate = Mapper.Map <CommandDC>(model.CommandItem);
                    CommandVMDC        returnedObject  = null;//sc.SaveCommand(SessionManager.UserID, SessionManager.UserID, "SecurityMonitoring", "", CommandToCreate);
                    var createdCommand = returnedObject.CommandItem;

                    model.CommandItem = Mapper.Map <CommandModel>(createdCommand);

                    //After creation some of the fields are display only so we need the resolved look up nmames
                    ResolveFieldCodesToFieldNamesUsingLists(model);

                    //model.AccessContext = CommandAccessContext.Edit;

                    //SessionManager.CommandDBVersion = model.CommandItem;
                    //SessionManager.CurrentCommand = model.CommandItem;

                    // Remove the state from the model as these are being populated by the controller and the HTML helpers are being populated with
                    // the POSTED values and not the changed ones.
                    ModelState.Clear();
                    model.Message = Resources.MESSAGE_UPDATE_SUCCEEDED;
                }
                catch (Exception e)
                {
                    model.Message = Resources.MESSAGE_UPDATE_FAILED;
                    return(View(model));
                }
            }

            return(View(model));
        }
Beispiel #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="userName"></param>
        /// <param name="currentUserName"></param>
        /// <param name="appID"></param>
        /// <param name="overrideID"></param>
        /// <param name="dc"></param>
        /// <param name="dataRepository"></param>
        /// <param name="uow"></param>
        public void CreateCommand(string userName, string currentUserName, string appID, string overrideID, CommandDC dc, IRepository <Command> dataRepository, IUnitOfWork uow)
        {
            try
            {
                using (uow)
                {
                    Command destination = Mapper.Map <CommandDC, Command>(dc);

                    dataRepository.Add(destination);

                    uow.Commit();
                }
            }
            catch (Exception e)
            {
                //Prevent exception from propogating across the service interface
                ExceptionManager.ShieldException(e);
            }
        }
Beispiel #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="userName"></param>
        /// <param name="currentUserName"></param>
        /// <param name="appID"></param>
        /// <param name="overrideID"></param>
        /// <param name="dc"></param>
        public void CreateCommand(string userName, string currentUserName, string appID, string overrideID, CommandDC dc)
        {
            IUnitOfWork uow = new UnitOfWork();

            Repository <Command> dataRepository = new Repository <Command>(uow.ObjectContext, userName, currentUserName, appID, overrideID);

            CreateCommand(userName, currentUserName, appID, overrideID, dc, dataRepository, uow);
        }