예제 #1
0
        public ActionResult AddAction(int StateActionStateId, int ClientId, string Message)
        {
            ClientStateAction clientStateAction = StateKey(ClientId, Message, StateActionStateId);

            if (clientStateAction == null)
            {
                clientStateAction = CreateClientStateAction(ClientId, Message, StateActionStateId);
            }

            db.ClientStateAction.Add(clientStateAction);
            db.SaveChanges();
            ViewBag.States       = db.ClientStates.ToList();
            ViewBag.Actions      = db.StateActions.ToList();
            ViewBag.ActionStates = db.StateActionState.ToList();
            var clientState = from c in db.ClientStateAction
                              where c.ClientId == ClientId
                              select c;

            ViewBag.CLientStateAction = clientState.ToList();
            List <int> InState = new List <int>();

            foreach (var ClientState in clientState.ToList())
            {
                StateActionState stateActionState = db.StateActionState.Find(ClientState.StateActionStateId);
                InState.Add(stateActionState.ClientStateId);
            }
            ViewBag.ActualState = InState.Max();

            return(PartialView("StateView"));
        }
예제 #2
0
        // GET: Clients/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Client client = db.Clients.Find(id);

            if (client == null)
            {
                return(HttpNotFound());
            }

            ViewBag.States       = db.ClientStates.ToList();
            ViewBag.Actions      = db.StateActions.ToList();
            ViewBag.ActionStates = db.StateActionState.ToList();
            var clientState = from c in db.ClientStateAction
                              where c.ClientId == id
                              select c;

            ViewBag.CLientStateAction = clientState.ToList();
            List <int> InState = new List <int>();

            foreach (var ClientState in clientState.ToList())
            {
                StateActionState stateActionState = db.StateActionState.Find(ClientState.StateActionStateId);
                InState.Add(stateActionState.ClientStateId);
            }

            ViewBag.ActualState = InState.Max();

            return(View(client));
        }
예제 #3
0
        public ActionResult Create([Bind(Include = "ClientStateId,Name")] ClientState clientState, int[] actions)
        {
            if (ModelState.IsValid)
            {
                db.ClientStates.Add(clientState);
                db.SaveChanges();
                StateActionState        stateActionState  = new StateActionState();
                List <StateActionState> stateActionStates = new List <StateActionState>();
                foreach (var action in actions)
                {
                    stateActionState.ClientStateId = clientState.ClientStateId;
                    stateActionState.StateActionId = action;
                    db.StateActionState.Add(stateActionState);
                    db.SaveChanges();
                }
                return(RedirectToAction("Index"));
            }

            return(View(clientState));
        }
예제 #4
0
파일: ADP.cs 프로젝트: Yvaine/M.S-P.P
 /// <summary>
 /// Gets N[s,a,s']'s if any exists or initializes it by 0.
 /// </summary>
 /// <param name="s">The state</param>
 /// <param name="a">The action</param>
 /// <param name="sprim">The next state</param>
 /// <returns>The value</returns>
 protected virtual NVal __get_nsas_value(State s, Action a, State sprim) { var sig = new StateActionState(s, new KeyValuePair<Action, State>(a, sprim)); if (!this.NSAS.Contains(sig)) this.NSAS.Add(sig, (NVal)0); return (NVal)this.NSAS[sig]; }
예제 #5
0
파일: ADP.cs 프로젝트: Yvaine/M.S-P.P
 /// <summary>
 /// Sets T-Value's value
 /// </summary>
 /// <param name="s">The state</param>
 /// <param name="a">The action</param>
 /// <param name="sprim">The next state</param>
 /// <param name="e">The value to be updated</param>
 protected virtual void __set_t_value(State s, Action a, State sprim, NVal e) { var sig = new StateActionState(s, new KeyValuePair<Action, State>(a, sprim)); if (!this.TTable.Contains(sig)) this.TTable.Add(sig, e); else this.TTable[sig] = e; }
예제 #6
0
        public ClientStateAction StateKey(int ClientId, string Message, int StateActionStateId)
        {
            ClientStateAction clientStateAction = null;

            StateActionState stateActionState = db.StateActionState.FirstOrDefault(s => s.StateActionStateId == StateActionStateId);
            StateAction      action           = db.StateActions.FirstOrDefault(x => x.StateActionId == stateActionState.StateActionId);

            StateActionState NewStateActionState;

            if (action.Name == "Rechazado")
            {
                NewStateActionState = db.StateActionState.FirstOrDefault(
                    s => s.ClientState.Name == "Rechazado" && s.StateAction.Name == "Rechazado");
                clientStateAction = CreateClientStateAction(ClientId, Message, NewStateActionState.StateActionStateId);
            }

            switch (stateActionState.ClientState.Name)
            {
            case "Lead":
                if (action.Name == "Llamada")
                {
                    NewStateActionState = db.StateActionState.FirstOrDefault(
                        s => s.ClientState.Name == "Contacto" && s.StateAction.Name == "llamada");
                    clientStateAction = CreateClientStateAction(ClientId, Message, NewStateActionState.StateActionStateId);
                }
                break;

            case "Contacto":
                if (action.Name == "Cita")
                {
                    NewStateActionState = db.StateActionState.FirstOrDefault(
                        s => s.ClientState.Name == "Visita" && s.StateAction.Name == "Cita");
                    clientStateAction = CreateClientStateAction(ClientId, Message, NewStateActionState.StateActionStateId);
                }
                break;

            case "Visita":
                if (action.Name == "Venta realizada")
                {
                    NewStateActionState = db.StateActionState.FirstOrDefault(
                        s => s.ClientState.Name == "Venta" && s.StateAction.Name == "Venta realizada");
                    clientStateAction = CreateClientStateAction(ClientId, Message, NewStateActionState.StateActionStateId);
                }
                break;

            case "Venta":
                if (action.Name == "Cerrar")
                {
                    NewStateActionState = db.StateActionState.FirstOrDefault(
                        s => s.ClientState.Name == "Vendido" && s.StateAction.Name == "Venta realizada");
                    clientStateAction = CreateClientStateAction(ClientId, Message, NewStateActionState.StateActionStateId);
                }
                break;

            case "Rechazado":
                if (action.Name == "Recuperar cliente")
                {
                    ClientStateAction clientStateActionToDelete = db.ClientStateAction.FirstOrDefault(
                        c => c.ClientId == ClientId && c.StateActionState.ClientState.Name == "Rechazado");
                    db.ClientStateAction.Remove(clientStateActionToDelete);
                    db.SaveChanges();
                    NewStateActionState = db.StateActionState.FirstOrDefault(
                        s => s.ClientState.Name == "Contacto" && s.StateAction.Name == "Informacion");
                    clientStateAction = CreateClientStateAction(ClientId, Message, NewStateActionState.StateActionStateId);
                }
                break;

            default:
                clientStateAction = null;
                break;
            }

            return(clientStateAction);
        }
예제 #7
0
 public PlanetState(FactionOwnedState factionState, TileableState tileableState, Sprite icon, long id, FactoryStamp stamp, NamedState namedState, AppearablePositionState positionState, StateActionState actionState) :
     base(icon, id, stamp, namedState, positionState, factionState, actionState)
 {
     this.tileableState = tileableState;
 }
예제 #8
0
 public StarNodeState(StarAsContainerState asContainerState, Sprite icon, long id, FactoryStamp stamp, NamedState namedState, AppearablePositionState positionState, FactionOwnedState factionOwned, StateActionState actionState) : base(icon, id, stamp, namedState, positionState, factionOwned, actionState)
 {
     this.asContainerState = asContainerState;
 }