Example #1
0
        public bool AddAction(AddActionDTO addActionDTO)
        {
            try
            {
                Models.Action lastAction = GetLastAction(addActionDTO);

                if (lastAction != null && CompareDates(DateTime.Now, lastAction.Date, 900))
                {
                    return(true);
                }

                Models.Action action = new Models.Action()
                {
                    ActionTypeId = addActionDTO.ActionTypeId,
                    Ip           = addActionDTO.Ip,
                    Date         = DateTime.Now,
                    DeviceTypeId = addActionDTO.DeviceTypeId
                };

                dbContext.Actions.Add(action);
                dbContext.SaveChanges();

                if (dbContext.IpLocations.FirstOrDefault(x => x.Ip == addActionDTO.Ip) == null)
                {
                    AddIpLocation(addActionDTO.Ip);
                }

                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
Example #2
0
 public ActionResult DeleteConfirmed(int id)
 {
     Models.Action action = db.Actions.Find(id);
     db.Actions.Remove(action);
     db.SaveChanges();
     return(RedirectToAction("Index"));
 }
        /// <summary>
        ///
        /// </summary>
        /// <param name="action"></param>
        /// <returns></returns>
        public bool SaveAction(Models.Action action)
        {
            try
            {
                int actionId = 0;
                using (var dbc = DatabaseHelper.GetConnector())
                {
                    using (var cmd = dbc.BuildStoredProcedureCommand("spSaveAction",
                                                                     "@characterId", action.CharacterId,
                                                                     "@encounterId", action.EncounterId,
                                                                     "@targetCharacterId", action.TargetCharacterId,
                                                                     "@actionTypeId", action.ActionType?.Id,
                                                                     "@value", action.Value,
                                                                     "@flavorText", action.FlavorText))
                        actionId = (int)cmd.ExecuteScalar();

                    foreach (var status in action.InflictedStatuses)
                    {
                        using (var cmd = dbc.BuildStoredProcedureCommand("spAddStatusToAction", "@actionId", actionId, "@statusId", status.Id))
                            cmd.ExecuteNonQuery();
                    }
                }
            }
            catch (Exception ex)
            {
                _log.Error(ex);
                return(false);
            }

            return(true);
        }
Example #4
0
        public void AddActionToNonconformity(int id, Models.Action action)
        {
            Nonconformity nonconformity = _context.Nonconformities.FirstOrDefault(p => p.Id == id);

            nonconformity?.Actions?.Add(action);
            _context.SaveChanges();
        }
Example #5
0
        public void ReadXml_Actions(string file_name)
        {
            ClearActions();
            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.Load(file_name);
            XmlNodeList nodelist = xmlDoc.DocumentElement.SelectNodes("/WPG/WP_Action_List/WP_Action");

            foreach (XmlNode top_action_node in nodelist)
            {
                //string text;
                Models.Action action = new Models.Action();
                action.name = top_action_node.SelectSingleNode("Name").InnerText;
                //text = "Name : " + action.name + "\n\n";
                XmlNodeList action_list = top_action_node.SelectNodes("./Action_List/Action");
                int[,] array = new int[15, 2];
                int count = 0;

                foreach (XmlNode xmlaction in action_list)
                {
                    array[count, 0] = Convert.ToInt16(xmlaction.SelectSingleNode("Type").InnerText);
                    array[count, 1] = Convert.ToInt16(xmlaction.SelectSingleNode("Param").InnerText);
                    //text = text + "Action (" + Convert.ToString(count) + ")\n";
                    //text = text + "\tType : " + Convert.ToString(array[count, 0])+ "\n";
                    //text = text + "\tParam"+ Convert.ToString(array[count, 1]) + "\n";
                    //MessageBox.Show(text, "xxx");
                    count++;
                }
                action.actions = array;
                AddAction(action);
            }
        }
Example #6
0
        public string GetHeaders([FromBody] Models.Action action)
        {
            var headers = Request.Headers;
            var header  = headers.GetValues("Cache-Control").First();

            return(header);
        }
Example #7
0
        public Questionnaire(int idAction)
        {
            InitializeComponent();
            actAssoc = idAction;

            using (Models.pyrenactionEntities context = new Models.pyrenactionEntities())
            {
                //On récupère le questionnaire associé à l'action
                Models.Action action = (from A in context.Actions where A.id == idAction select A).FirstOrDefault();

                if (action != null)
                {
                    _questionnaireController = new QuestionnaireViewModel(action.Questionnaire);
                    this.DataContext         = _questionnaireController;

                    var query = from Q in context.Questions where Q.id_Questionnaire == action.Questionnaire.id select Q;
                    List <Models.Question> listeQuestions = query.ToList();

                    //Questions
                    textBlock1.Text = listeQuestions[0].intitule;
                    textBlock2.Text = listeQuestions[1].intitule;
                    textBlock3.Text = listeQuestions[2].intitule;
                    textBlock4.Text = listeQuestions[3].intitule;
                    textBlock5.Text = listeQuestions[4].intitule;

                    //Réponses
                    inputQ1.IsChecked = listeQuestions[0].reponse;
                    inputQ2.IsChecked = listeQuestions[1].reponse;
                    inputQ3.IsChecked = listeQuestions[2].reponse;
                    inputQ4.IsChecked = listeQuestions[3].reponse;
                    inputQ5.IsChecked = listeQuestions[4].reponse;
                }
            }
        }
Example #8
0
        private void Suicide(string agentId)
        {
            var agentToUpdate = this.Context.Agents.First(a => a.Id == agentId);

            agentToUpdate.Life   = 0;
            agentToUpdate.Status = Constantes.AGENT_STATUS_DEAD;
            var killer = this.Context.Agents.First(a => a.TargetId == agentId);

            killer.TargetId = agentToUpdate.TargetId;
            Context.Update(agentToUpdate);
            Context.Update(killer);
            Models.Action action = new Models.Action()
            {
                GameId     = agentToUpdate.GameId,
                KillerId   = agentToUpdate.Id,
                KillerName = agentToUpdate.Name,
                Type       = Constantes.ACTTION_TYPE_SUICIDE
            };
            this.Context.Actions.Add(action);

            this.SendToAll(agentToUpdate.GameId.ToString(), Constantes.REQUEST_METHOD_NAME, new Request()
            {
                Type       = Constantes.REQUEST_TYPE_AGENT_UPDATE,
                ReceiverId = killer.Id,
                IsTreated  = true
            });
        }
Example #9
0
        private void Unmask(string victimId)
        {
            // Killer => Victim => Target
            //Target unmask victim
            var victimToUpdate = this.Context.Agents.First(a => a.Id == victimId);
            var target         = this.Context.Agents.First(a => a.Id == victimToUpdate.TargetId);
            var killer         = this.Context.Agents.First(a => a.TargetId == victimId);

            killer.TargetId = target.Id;
            if (target.Life < 5)
            {
                target.Life++;
            }

            victimToUpdate.Life      = 0;
            victimToUpdate.Status    = "dead";
            victimToUpdate.MissionId = null;
            victimToUpdate.TargetId  = null;

            var action = new Models.Action()
            {
                GameId     = victimToUpdate.GameId,
                TargetId   = victimToUpdate.Id,
                TargetName = victimToUpdate.Name,
                KillerId   = target.Id,
                KillerName = target.Name,
                Type       = Constantes.ACTTION_TYPE_UNMASK
            };

            this.Context.Agents.UpdateRange(new List <Agent> {
                victimToUpdate, killer, target
            });
            this.Context.Actions.Add(action);
        }
        private static Models.Action ParseAction(Microsoft.AspNetCore.Mvc.Abstractions.ActionDescriptor actionDescriptor)
        {
            var action = new Models.Action
            {
                Template   = actionDescriptor.AttributeRouteInfo.Template,
                Parameters = actionDescriptor.Parameters
                             .Select(p => new Parameter {
                    Name = p.Name, Type = p.ParameterType.FullName
                })
                             .ToList()
            };

            if (actionDescriptor.ActionConstraints != null)
            {
                for (var i = 0; i < actionDescriptor.ActionConstraints.Count; i++)
                {
                    var actionDescriptorActionConstraint = actionDescriptor.ActionConstraints[i];
                    if (actionDescriptorActionConstraint is HttpMethodActionConstraint httpMethodActionConstraint)
                    {
                        action.Methods.AddRange(httpMethodActionConstraint.HttpMethods);
                    }
                }
            }

            return(action);
        }
Example #11
0
        // GET: Questions/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var user = Session["user"] as Account;

            Models.Action action = db.Actions.Where(p => p.ActionId == id).SingleOrDefault();
            if (action == null || user == null || user.AccountId != action.AccountId)
            {
                return(HttpNotFound());
            }
            ViewBag.AccountId = new SelectList(db.Accounts, "AccountId", "FirstName", action.AccountId);
            ViewBag.ActionId  = new SelectList(db.Actions, "ActionId", "Text", action.ActionId);
            if (action is Question)
            {
                ViewBag.CategoryId = new SelectList(db.Categories, "CategoryId", "Name", (action as Question).CategoryId);
            }
            if (action is Question)
            {
                return(View(action as Question));
            }
            return(View("EditResponse", action as Response));
        }
        public async Task <string> PostMoistureAsync(double value)
        {
            var val = value / 10;
            await HubContext.Clients.All.SendAsync("PushSoilSensorData", val);

            if (val > 50)
            {
                using (appDB)
                {
                    Models.Action act = new Models.Action()
                    {
                        Text = "Farm will need water soon ",
                        Act  = 4
                    };

                    if (val > 70)
                    {
                        act.Text = "farm needs watering ";
                        act.Act  = 3;
                    }
                    ActionRepository repo = new ActionRepository(appDB);
                    await repo.InsertAsync(act);
                }
            }
            return("OK");
        }
        public static async Task SendPatchMessageAsync(Models.Action action, Guid customerId, string reqUrl)
        {
            var tokenProvider    = TokenProvider.CreateSharedAccessSignatureTokenProvider(KeyName, AccessKey);
            var messagingFactory = MessagingFactory.Create(BaseAddress, tokenProvider);
            var sender           = messagingFactory.CreateMessageSender(QueueName);

            var messageModel = new MessageModel
            {
                TitleMessage     = "Action record modification for {" + customerId + "} at " + DateTime.UtcNow,
                CustomerGuid     = customerId,
                LastModifiedDate = action.LastModifiedDate,
                URL           = reqUrl,
                IsNewCustomer = false,
                TouchpointId  = action.LastModifiedTouchpointId
            };

            var msg = new BrokeredMessage(new MemoryStream(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(messageModel))))
            {
                ContentType = "application/json",
                MessageId   = customerId + " " + DateTime.UtcNow
            };

            //msg.ForcePersistence = true; Required when we save message to cosmos
            await sender.SendAsync(msg);
        }
        public async Task <string> PostAsync([FromBody] SensorData data)
        {
            data.Optimize();

            await HubContext.Clients.All.SendAsync("PushSensorData", data);

            using (appDB)
            {
                SensorDataRepository Srepo = new SensorDataRepository(appDB);
                await Srepo.InsertAsync(data);

                if (data.SoilMoisture > 50)
                {
                    Models.Action act = new Models.Action()
                    {
                        Text = "Farm will need water soon ",
                        Act  = 4
                    };

                    if (data.SoilMoisture > 70)
                    {
                        act.Text = "farm needs watering ";
                        act.Act  = 3;
                    }
                    ActionRepository repo = new ActionRepository(appDB);
                    await repo.InsertAsync(act);
                }
            }

            return("OK");
        }
Example #15
0
 public static void ExecuteAction(Models.Action action, Hero player)
 {
     if (action.Name != "LEVEL UP CRITICAL STRIKE")
     {
         HeroCooldownReductor.ReduceCooldowns(player);
         IPassiveActivator hero = (IPassiveActivator)player;
         hero.ActivatePassive(action.Name, player);
         ActionResult.ShowActionResult($"{player.Name} ACTIVATED {action.Name}!");
     }
     else
     {
         SwordmasterWarrior swordmaster = (SwordmasterWarrior)player;
         if (swordmaster.CriticalStrike)
         {
             var key = new ConsoleKeyInfo();
             while (key.Key != ConsoleKey.Enter)
             {
                 Console.Clear();
                 Console.ForegroundColor = ConsoleColor.Red;
                 Console.WriteLine(Constants.GameTitle);
                 Console.WriteLine($"CRITICAL STRIKE HAS ALREADY BEEN LEVELED UP! SELECT DIFFERENT ACTION!");
                 Console.WriteLine("-- PRESS ENTER TO CONTINUE TO ACTION MENU --");
                 key = Console.ReadKey();
             }
             Combat.PlayerTurn(player);
         }
         else
         {
             HeroCooldownReductor.ReduceCooldowns(player);
             IPassiveActivator hero = (IPassiveActivator)player;
             hero.ActivatePassive(action.Name, player);
             ActionResult.ShowActionResult($"{player.Name} ACTIVATED {action.Name}!");
         }
     }
 }
 //constructeur par défault
 public ActionViewModel(Models.Action action)
 {
     _action        = action;
     _action.statut = false;
     _context       = new Models.pyrenactionEntities();
     loadFields();
 }
Example #17
0
        public Models.Action ShouldTestWell(double healthIndex, int lastTestDay, int today, CancellationToken cancellationToken)
        {
            var testGap = today - lastTestDay;

            //SKIP_TEST_SAFE: anomaly prob = 0
            //SKIP_TEST_OK: anomaly prob = defined in data, per well
            //SKIP_TEST_RISKY: anomaly prob = 1
            var actionId =
                testGap > 60
                ? "Risky To Skip Test"
                : healthIndex >= 0.96
                ? "Safe To Skip Test"
                : healthIndex >= 0.5 && healthIndex < 0.96
                ? "OK To Skip Test"
                : "Risky To Skip Test";

            var action = new Models.Action();

            action.id   = actionId;
            action.name = actionId;
            action.type = "Cost Reduction";


            return(action);
        }
        public IActionResult Delete(Guid id)
        {
            Models.Action action = _actionRepository.GetActionByID(id);

            _actionRepository.DeleteAction(id);
            return(new OkResult());
        }
Example #19
0
 public ActionResult Question(int?id, SortTypes?sort = null, int?channel = null)
 {
     if (sort != null)
     {
         if (sort == SortTypes.Time)
         {
             ViewBag.Responses = db.Actions.OfType <Response>().Where(r => r.RespondingTo.ActionId == id).OrderByDescending(o => o.CreatedAt).ToList();
         }
         else if (sort == SortTypes.Votes)
         {
             ViewBag.Responses = db.Actions.OfType <Response>().Where(r => r.RespondingTo.ActionId == id).OrderByDescending(o => o.Upvotes).ToList();
         }
     }
     else
     {
         ViewBag.Responses = db.Actions.OfType <Response>().Where(r => r.RespondingTo.ActionId == id).ToList();
     }
     ViewBag.canReply = true;
     if (channel != null)
     {
         var user = Session["user"] as Account;
         if (user.Role != AccountRole.Client)
         {
             var ch = db.Channels.Where(c => c.ChannelId == channel).Include(c => c.Agents).FirstOrDefault();
             ViewBag.canReply = ch.Agents.ToList().Find(u => u.AccountId == user.AccountId) != null;
         }
     }
     Models.Action a = db.Actions.Find(id) as Models.Action;
     return(View(a));
 }
        public async Task <IActionResult> PutAction(int id, Models.Action action)
        {
            if (id != action.Id)
            {
                return(BadRequest());
            }

            _context.Entry(action).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ActionExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Example #21
0
        // GET: Questions/Delete/5
        public ActionResult Delete(int?id)
        {
            var  user    = Session["user"] as Account;
            bool isAdmin = false;

            if (user != null && user.Role == AccountRole.Admin)
            {
                isAdmin = true;
            }
            Models.Action action = db.Actions.Where(p => p.ActionId == id).SingleOrDefault();
            if (user.AccountId == action.AccountId)
            {
                isAdmin = true;
            }
            if (id == null || !isAdmin)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }


            if (action == null)
            {
                return(HttpNotFound());
            }
            return(View(action));
        }
        public async Task <ActionResult <Models.Action> > PostAction(Models.Action action)
        {
            _context.Action.Add(action);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetAction", new { id = action.Id }, action));
        }
Example #23
0
        private void Kill(string victimId, Agent killerToUpdate)
        {
            var mission        = killerToUpdate.Mission;
            var victimToUpdate = this.Context.Agents.First(a => a.Id == victimId);
            var newTarget      = this.Context.Agents.First(a => a.Id == victimToUpdate.TargetId);

            killerToUpdate.MissionId = victimToUpdate.MissionId;
            killerToUpdate.TargetId  = newTarget.Id;
            if (killerToUpdate.Life < 5)
            {
                killerToUpdate.Life++;
            }

            victimToUpdate.Life      = 0;
            victimToUpdate.Status    = "dead";
            victimToUpdate.MissionId = null;
            victimToUpdate.TargetId  = null;

            var action = new Models.Action()
            {
                GameId       = killerToUpdate.GameId,
                TargetId     = victimToUpdate.Id,
                TargetName   = victimToUpdate.Name,
                KillerId     = killerToUpdate.Id,
                KillerName   = killerToUpdate.Name,
                Type         = Constantes.ACTTION_TYPE_KILL,
                MissionId    = mission.Id,
                MissionTitle = mission.Title
            };

            this.Context.Agents.UpdateRange(new List <Agent> {
                killerToUpdate, victimToUpdate
            });
            this.Context.Actions.Add(action);
        }
Example #24
0
        public IActionResult ActionTruck(fireActionTrack truck)
        {
            var lista = _context.Actions.Where(a => a.EndTime > DateTime.Now).Select(x => x.IdAction);

            int sumaAktywnosci = _context.FireTruck_Actions.Where(a => lista.Contains(a.IdAction) && a.IdFireTruck == truck.idFireTruck).Count();

            if (sumaAktywnosci > 0)
            {
                return(BadRequest("Samochód w użyciu"));
            }


            FireTruck tmp = _context.FireTrucks.Where(a => a.IdFireTruck == truck.idFireTruck).First();

            Models.Action act = _context.Actions.Where(a => a.IdAction == truck.idAction).First();

            act.FireTruck_Actions.Add(new FireTruck_Action {
                AssigmentDate = DateTime.Now, IdFireTruck = truck.idFireTruck, FireTruck = tmp, IdAction = act.IdAction, Action = act
            });

            _context.SaveChanges();


            return(Ok("Samochód dodany do akcji"));
        }
Example #25
0
        /// <summary>
        /// Posts an Action
        /// </summary>
        /// <param name="action">Required parameter: The action to be posted.</param>
        /// <return>Returns the Models.MessageResponse response from the API call</return>
        public Models.MessageResponse PostAction(Models.Action action)
        {
            Task <Models.MessageResponse> t = PostActionAsync(action);

            APIHelper.RunTaskSynchronously(t);
            return(t.Result);
        }
        public async Task <ActionResult <Trigger> > UnSetAction(int id, Models.Action action)
        {
            var trigger = await _context.Trigger.FindAsync(id);

            if (trigger == null)
            {
                return(BadRequest());
            }

            var tmpAction = await _context.Action.FirstOrDefaultAsync(e => e.Id == action.Id && e.Type == action.Type && e.Value == action.Value);

            if (tmpAction == null)
            {
                return(BadRequest());
            }

            trigger.RemoveAction(tmpAction);
            trigger.LastUpdated           = DateTime.Now;
            _context.Entry(trigger).State = EntityState.Modified;
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                throw;
            }
            return(NoContent());
        }
Example #27
0
        public async Task <ActionOutcome> WellActionOutcome(Well well, Models.Action action, CancellationToken cancellationToken)
        {
            var request = new GraphQLRequest();

            request.Variables = new { wellId = well.id, actionId = action.id };
            request.Query     = @" query($wellId: ID, $actionId: ID){
                actionOutcomeFilter(filters: [
                    {
                        fieldName: ""well""
                        op: ""==""
                        value: { ID: $wellId }
                    }
                    {
                        fieldName: ""action""
                        op: ""==""
                        value: { ID: $actionId }
                    }
                ]) 
                {
                    id
                    action {
                        id
                        name
                        type
                    }
                    well {
                        id
                        name
                    }
                    probabilityOfAnomaly
                    cost
                    manHours
                    increaseInOilRate
                }
            }";

            var response = await Client.GetClientInstance().PostAsync(request);

            var outcomes = response.GetDataFieldAs <List <ActionOutcome> >("actionOutcomeFilter");

            ActionOutcome actionOutcome;

            if (outcomes != null && outcomes.Count > 0)
            {
                actionOutcome = outcomes.First();
            }
            else
            {
                actionOutcome        = new ActionOutcome();
                actionOutcome.id     = "1";
                actionOutcome.action = action;
                actionOutcome.well   = well;
                actionOutcome.probabilityOfAnomaly = 0;
                actionOutcome.cost              = 0;
                actionOutcome.manHours          = 0;
                actionOutcome.increaseInOilRate = 0;
            }
            return(actionOutcome);
        }
Example #28
0
        public static void ExecuteAction(Models.Action action, Hero player, Hero target)
        {
            HeroCooldownReductor.ReduceCooldowns(player);
            IAgressiveAction currentAction = (IAgressiveAction)action;

            currentAction.ExecuteAgressiveAction(player, target);
            ActionResult.ShowActionResult($"{player.Name} USED {action.Name} ON HIS SWORN ENEMY {target.Name}!");
        }
Example #29
0
 private void bSetAction_Click(object sender, EventArgs e)
 {
     var addAction = new AddAction(_rule);
     addAction.ShowDialog();
     bSetAction.Text = "Action set!";
     bSetAction.Enabled = false;
     _action = addAction.GetAction();
 }
Example #30
0
        public string RenderAction(Models.Action action)
        {
            var sb = new StringBuilder();

            sb.AppendLine(action.Name);
            sb.AppendLine(action.Description);
            return(sb.ToString());
        }
Example #31
0
 public IHttpActionResult PostJSON([FromBody] Models.Action action)
 {
     if (manager.WriteAction(action) != 0)
     {
         return(Ok());
     }
     return(BadRequest());
 }
Example #32
0
 public Models.Action Create(ActionViewModel model)
 {
     var entity = new Models.Action();
     entity.ControllerID = model.ControllerID;
     entity.Name = model.Name;
     entity.Description = model.Description;
     db.Add<Models.Action>(entity);
     db.Commit();
     return entity;
 }
        public ActionResult Create(SaltedButterViewModel submittedPlace)
        {
            if (ModelState.IsValid)
            {
                Models.Place place = new Models.Place();
                string _address = "http://demo.places.nlp.nokia.com/places/v1/places/" + submittedPlace.PlaceId + "?app_id=EOXbMEWYAllPhQnAQsmn&app_code=9TIppnJDB9PHy8-ckJLWXA";
                HttpClient client = new HttpClient();
                client.DefaultRequestHeaders.Add("Accept", "application/json");

                // Send a request asynchronously continue when complete
                var taskGet = client.GetAsync(_address).ContinueWith(
                (requestTask) =>
                {
                    // Get HTTP response from completed task.
                    HttpResponseMessage response = requestTask.Result;

                    // Check that response was successful or throw exception
                    response.EnsureSuccessStatusCode();

                    response.Content.ReadAsAsync(typeof(NokiaPlace)).ContinueWith(
                    (readTask) =>
                    {
                        // Mapping information provided by API
                        NokiaPlace nokiaPlace = (NokiaPlace)readTask.Result;
                        place.Address1 = nokiaPlace.Location.Address["street"];
                        place.City = nokiaPlace.Location.Address["city"];
                        place.PostalCode = nokiaPlace.Location.Address["postalCode"];
                        place.Country = nokiaPlace.Location.Address["country"];
                        place.Latitude = nokiaPlace.Location.Position[0];
                        place.Longitude = nokiaPlace.Location.Position[1];
                    });

                });

                place.Name = submittedPlace.Name;

                Models.User user = new Models.User(){
                    Email = submittedPlace.Email,
                    Username = submittedPlace.UserName,
                    CreationDate = DateTime.Now
                };

                Models.SaltedButter saltedButter = new Models.SaltedButter()
                {
                    Salted = Convert.ToBoolean(submittedPlace.Status),
                    Comment = submittedPlace.Comment
                };

                taskGet.Wait();

                Models.Action action = new Models.Action()
                {
                    Place = place,
                    SaltedButter = saltedButter,
                    User = user,
                    CreationDate = DateTime.Now,
                    StatusId = 1,
                    CategoryId = 1
                };

                _dataContext.Actions.InsertOnSubmit(action);

                _dataContext.SubmitChanges();

                MapViewModel map = new MapViewModel()
                {
                    Latitude = place.Latitude,
                    Longitude = place.Longitude
                };

                //_dataContext.Places.InsertOnSubmit(place);
                TempData["success"] = "ok"; // Indicating to display ok notification after redirection
                return RedirectToAction("Index", "Map", map);

            }

            return PartialView("NoteAdd",submittedPlace);
        }
Example #34
0
        private void bSaveAction_Click(object sender, EventArgs e)
        {
            var ruleSelected = _rule != null;
            var destinationSelected = add_cbCommunicatorDestination.SelectedItem != null;
            var outputEntered = add_tOutputValue.Text != "";

            if (!(ruleSelected && destinationSelected && outputEntered))
            {
                DebugOutput.Print("Unable to save - not all data has been entered!");
                return;
            }

            _communicator = (Models.Communicator)add_cbCommunicatorDestination.SelectedItem;

            var newAction = new Models.Action()
            {
                Rule   = _rule,
                RuleId = _rule.Id,
                Communicator =_communicator,
                CommunicatorId = _communicator.Id,
                OutputValue = add_tOutputValue.Text,
                Enabled = add_cActionEnabled.Checked
            };

            var controller = new ActionController();
            var action = controller.CreateAction(newAction);

            if (action != null)
            {
                DebugOutput.Print("Successfully created a new Action.");
                this.Close();
            }
        }