Ejemplo n.º 1
0
        public ActionResult PerformCreateAndAddRelation(long relationTypeId, long entityId, FormCollection formCollection)
        {
            TEntity entity = Model.GetEntity(entityId);

            if (entity == null || !entity.IsEditable)
            {
                return(RedirectToAction("Index"));
            }

            // TODO better check of relationTypeId validity.
            RelationModel  relationModel = RemoteFacade.Instance.GetModel <RelationModel> (db);
            TypedRelations relations     = relationModel.GetRelations(relationTypeId, entity);

            if (relations == null)
            {
                return(RedirectToAction("Index"));
            }

            Entity newEntity = relationModel.GetNewObjectiveEntity(relations.RelationType, String.Empty);

            TryUpdateModel(relations.RelationType.ObjectiveEntityType, newEntity, "NewEntity");
            if (ModelState.IsValid)
            {
                newEntity = RemoteFacade.Instance.GetEntityModel(newEntity.GetType(), db).AddNewEntity(newEntity);
                relationModel.AddRelation(relationTypeId, entity, newEntity.Id);
                return(RedirectToAction("Relations", new { RelationTypeId = relationTypeId, EntityId = entityId }));
            }

            return(View(CreateAndAddRelationView, new CreateAndAddRelationViewModel()
            {
                Entity = entity,
                RelationTypeId = relationTypeId,
                NewEntity = (Entity)newEntity
            }));
        }
 public FileSystemIndexConfigurator(string directory, Model model, string name)
 {
     _directory = directory;
     _model = model;
     _entityMap = model.GetEntity(name);
     _indexes = new IndexConfigurationConverter(model, _entityMap).Convert();
 }
Ejemplo n.º 3
0
        public ActionResult Edit(long id, FormCollection formCollection)
        {
            TEntity entity = Model.GetEntity(id);

            if (entity == null || !entity.IsEditable)
            {
                return(RedirectToAction("Index"));
            }

            // The identification of the entity has to be remembered because some of the fields, that involve the identification
            // could been filled invalidly. That would cause that invalid identifaction of the entity is displayed.
            string validIdentification = entity.Identification;

            TryUpdateModel(entity, "Entity");
            if (ModelState.IsValid)
            {
                Model.SaveEntity(entity);
                return(RedirectToDetail(entity));
            }

            return(View(EditView, new EntityEditViewModel()
            {
                Entity = entity,
                Identification = validIdentification
            }));
        }
 public void ProcessEvent(Model model, Dictionary ev)
 {
     if ((string)ev["action"] == "Move" && !movePrompt)
     {
         movePrompt = true;
         model.CoolerApiEvent(-1, "Print", "Use the numpad to move. Hold Ctrl to move 5 spaces.");
         model.CoolerApiEvent(-1, "Print", "Or, click to path somewhere. (Use arrow keys if you must.)");
     }
     if ((string)ev["action"] == "Downed")
     {
         Entity subject = model.GetEntity((int)ev["subject"]);
         if (subject.team != 0 && !abilitiesPrompt)
         {
             abilitiesPrompt = true;
             model.CoolerApiEvent(-1, "Print", "Press A for [A]bilities!");
         }
         if (subject.id == 0)
         {
             DumpStats(model);
         }
     }
     if ((string)ev["action"] == "Exit")
     {
         DumpStats(model);
     }
 }
Ejemplo n.º 5
0
        public ActionResult CreateAndAddRelation(long relationTypeId, long entityId, string relatedEntityId)
        {
            TEntity entity = Model.GetEntity(entityId);

            if (entity == null || !entity.IsEditable)
            {
                return(RedirectToAction("Index"));
            }

            // TODO better check of relationTypeId validity.
            RelationModel  relationModel = RemoteFacade.Instance.GetModel <RelationModel> (db);
            TypedRelations relations     = relationModel.GetRelations(relationTypeId, entity);

            if (relations == null)
            {
                return(RedirectToAction("Index"));
            }

            return(View(CreateAndAddRelationView, new CreateAndAddRelationViewModel()
            {
                Entity = entity,
                RelationTypeId = relationTypeId,
                NewEntity = relationModel.GetNewObjectiveEntity(relations.RelationType, relatedEntityId)
            }));
        }
Ejemplo n.º 6
0
        void OnSave(object sender, EventArgs e)
        {
            var repository = new PropertyRepository();

            repository.SaveOrUpdate(Model.GetEntity());

            Navigation.PopAsync();
        }
Ejemplo n.º 7
0
        public ActionResult AddRelation(long relationTypeId, long entityId, long relatedEntityId)
        {
            TEntity entity = Model.GetEntity(entityId);

            if (entity != null)
            {
                RemoteFacade.Instance.GetModel <RelationModel> (db).AddRelation(relationTypeId, entity, relatedEntityId);
            }
            return(RedirectToAction("Relations", new { RelationTypeId = relationTypeId, EntityId = entityId }));
        }
Ejemplo n.º 8
0
        public ActionResult DeleteRelation(long relationTypeId, long entityId, long relationId)
        {
            TEntity entity = Model.GetEntity(entityId);

            if (entity != null && entity.IsEditable)
            {
                RemoteFacade.Instance.GetModel <RelationModel> (db).DeleteRelation(relationTypeId, entity, relationId);
            }
            return(RedirectToAction("Relations", new { RelationTypeId = relationTypeId, EntityId = entityId }));
        }
Ejemplo n.º 9
0
        public ActionResult Publications(long id)
        {
            TEntity informativeEntity = Model.GetEntity(id);

            if (informativeEntity == null)
            {
                return(RedirectToAction("Index"));
            }

            return(View("Entity/InformativeEntity/Publications", informativeEntity));
        }
Ejemplo n.º 10
0
        public ActionResult Close(long id)
        {
            Incident incidentToClose = Model.GetEntity(id);

            if (incidentToClose == null || !incidentToClose.IsEditable)
            {
                return(RedirectToAction("Index"));
            }

            return(View(incidentToClose));
        }
Ejemplo n.º 11
0
        public ActionResult Close(long id)
        {
            Report report = Model.GetEntity(id);

            if (report == null)
            {
                return(RedirectToAction("Index"));
            }

            Model.CloseReport(report);
            return(RedirectToDetail(report));
        }
Ejemplo n.º 12
0
 public void ProcessEvent(Model model, Dictionary ev)
 {
     if ((string)ev["action"] == "Move")
     {
         Entity subject = model.GetEntity((int)ev["subject"]);
         if (subject.team == 0)
         {
             UpdateVision(model, subject);
             subject.dirtyVision = false;
         }
     }
 }
Ejemplo n.º 13
0
        public ActionResult Open(long id)
        {
            Incident incidentToOpen = Model.GetEntity(id);

            if (incidentToOpen == null)
            {
                return(RedirectToAction("Index"));
            }

            Model.OpenIncident(incidentToOpen);
            return(RedirectToDetail(incidentToOpen));
        }
Ejemplo n.º 14
0
        public ActionResult Close(long id, FormCollection formCollection)
        {
            Incident incidentToClose = Model.GetEntity(id);

            if (incidentToClose == null || !incidentToClose.IsEditable)
            {
                return(RedirectToAction("Index"));
            }

            TryUpdateModel(incidentToClose);
            Model.CloseIncident(incidentToClose);
            return(RedirectToDetail(incidentToClose));
        }
Ejemplo n.º 15
0
        public JsonResult SearchForRelatableEntities(long relationTypeId, long entityId, string needle)
        {
            TEntity entity = Model.GetEntity(entityId);

            if (entity != null)
            {
                return(new JsonResult()
                {
                    Data = SerializeEntities(RemoteFacade.Instance.GetModel <RelationModel> (db).GetRelatableEntities(
                                                 relationTypeId, entity, needle))
                });
            }
            return(new JsonResult());
        }
Ejemplo n.º 16
0
        public ActionResult Delete(long id)
        {
            TEntity entity = Model.GetEntity(id);

            if (entity == null)
            {
                return(RedirectToAction("Index"));
            }

            return(View(DeleteView, new EntityViewModel()
            {
                Entity = entity
            }));
        }
Ejemplo n.º 17
0
        public ActionResult Edit(long id)
        {
            TEntity entity = Model.GetEntity(id);

            if (entity == null || !entity.IsEditable)
            {
                return(RedirectToAction("Index"));
            }

            return(View(EditView, new EntityEditViewModel()
            {
                Entity = entity,
                Identification = entity.Identification
            }));
        }
    public void ProcessEvent(Model model, Dictionary ev)
    {
        if ((string)ev["action"] == "Downed")
        {
            Entity subject = model.GetEntity((int)ev["subject"]);
            if (subject.team != 0)
            {
                kills++;
            }
            else if (subject.id != 0)
            {
                partnerDead = true;
            }
        }

        if ((string)ev["action"] == "Hit" || (string)ev["action"] == "Rush")
        {
            Entity subject = model.GetEntity((int)ev["subject"]);
            if (subject.id == 0)
            {
                playerDamage += (int)(ev["damage"]); // ew
            }
            if (subject.id == 1)
            {
                partnerDamage += (int)(ev["damage"]);
            }
        }

        if ((string)ev["action"] == "Print")
        {
            if ((string)ev["args"] == "Got the moss.")
            {
                gotMoss = true;
            }
        }
    }
Ejemplo n.º 19
0
        public ActionResult Publish(long id)
        {
            TEntity informativeEntity = Model.GetEntity(id);

            if (informativeEntity == null || !informativeEntity.IsPublishable)
            {
                return(RedirectToAction("Index"));
            }

            return(View("Entity/InformativeEntity/Publish", new InformativeEntityPublicationViewModel()
            {
                Entity = informativeEntity,
                Publication = new Publication()
            }));
        }
Ejemplo n.º 20
0
        public ActionResult Detail(long id)
        {
            TEntity entity = Model.GetEntity(id);

            if (entity == null)
            {
                return(RedirectToAction("Index"));
            }

            return(View(DetailView, new EntityDetailViewModel()
            {
                Entity = entity,
                Relations = RemoteFacade.Instance.GetModel <RelationModel> (db).GetRelations(entity)
            }));
        }
Ejemplo n.º 21
0
        public ActionResult Relations(long relationTypeId, long entityId)
        {
            TEntity entity = Model.GetEntity(entityId);

            if (entity == null)
            {
                return(RedirectToAction("Index"));
            }

            TypedRelations relations = RemoteFacade.Instance.GetModel <RelationModel> (db).GetRelations(relationTypeId, entity);

            if (relations == null)
            {
                return(RedirectToAction("Index"));
            }

            return(View(RelationsView, new EntityRelationsViewModel()
            {
                Entity = entity,
                Relations = relations
            }));
        }
Ejemplo n.º 22
0
        public ActionResult Publish(long id, FormCollection formCollection)
        {
            TEntity informativeEntity = Model.GetEntity(id);

            if (informativeEntity == null || !informativeEntity.IsPublishable)
            {
                return(RedirectToAction("Index"));
            }

            Publication publication = new Publication();

            TryUpdateModel(publication, "Publication");
            if (ModelState.IsValid)
            {
                Model.Publish(informativeEntity, publication);
                return(RedirectToAction("Publications", new { Id = informativeEntity.Id }));
            }

            return(View("Entity/InformativeEntity/Publish", new InformativeEntityPublicationViewModel()
            {
                Entity = informativeEntity,
                Publication = publication
            }));
        }
Ejemplo n.º 23
0
 public MemoryIndexConfigurator(Model model, string name)
 {
     _model = model;
     _entityMap = model.GetEntity(name);
     _indexes = new IndexConfigurationConverter(model, _entityMap).Convert();
 }