public HttpResponseMessage GetAllTechnologies() { TechnologyService service = new TechnologyService(); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, service.GetAllTechnologies()); return(response); }
public void SetEntityStatusShouldUpdateTechnologyEntitiesStatus() { var technologyService = new TechnologyService(); var technology = new Technology("C++", "c++", "Languages and Frameworks", "", ""); var entity = new Entity() { Name = "1", Id = "5c73c15a8b89521e44e98804", Technologies = new EntityTechnology[] { new EntityTechnology(technology.Id, "Status", new EntityTechnologyUrl[0]), } }; var expected = new EntityStatus() { EntityId = entity.Id, EntityName = entity.Name, Status = "Status" }; var newTechnology = technologyService.SetEntityStatus(technology, entity, "id"); var actual = newTechnology.EntitiesStatus.First(); Assert.Equal(expected.Status, actual.Status); Assert.Equal(expected.EntityName, actual.EntityName); Assert.Equal(expected.EntityId, actual.EntityId); }
public ActionResult DeleteConfirmed(int id) { TechnologyService technologyService = db.TechnologyServices.Find(id); db.TechnologyServices.Remove(technologyService); db.SaveChanges(); return(RedirectToAction("Index")); }
public HttpResponseMessage GetTechnologyById(int TechId) { TechnologyService service = new TechnologyService(); Technology TechObj = service.GetTechnologyById(TechId); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, TechObj); return(response); }
public ActionResult Edit([Bind(Include = "TechServiceID,ServiceName,ServiceOwner")] TechnologyService technologyService) { if (ModelState.IsValid) { db.Entry(technologyService).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(technologyService)); }
public ActionResult Create([Bind(Include = "TechServiceID,ServiceName,ServiceOwner")] TechnologyService technologyService) { if (ModelState.IsValid) { db.TechnologyServices.Add(technologyService); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(technologyService)); }
public ActionResult TechDetail(int technologyId) { var ts = new TechnologyService(); var vm = new TechDetailViewModel() { Technology = ts.GetById(technologyId) }; vm.StatusId = ts.GetUserTechnologies().Where(x => x.UserId.Equals(this.UserContext.Id) && x.TechnologyId.Equals(technologyId)).Select(x => (UserTechnologyStatusTypes?)x.StatusId).FirstOrDefault(); return(View(vm)); }
// GET: Research public ActionResult Index() { var ts = new TechnologyService(); var vm = new ResearchViewModel(); vm.Technologies = ts.GetTechnologies().ToList(); vm.ResearchedTechnologyIds = ts.GetResearchedTechnologyIds(this.UserContext.Id); vm.CurrentlyResearching = ts.GetCheckPendingResearch(this.UserContext.Id); ts.SaveChanges(); return(View(vm)); }
public HttpResponseMessage DeleteTechnology(int TechId) { TechnologyService service = new TechnologyService(); service.DeleteTechnology(new Technology { TechnologyId = TechId, DeletedBy = this.Request.Headers.GetValues("username").First() }); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, "deleted technology details sucessfully"); return(response); }
// GET: TechnologyServices/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } TechnologyService technologyService = db.TechnologyServices.Find(id); if (technologyService == null) { return(HttpNotFound()); } return(View(technologyService)); }
public async Task GetAllTechnologiesShouldReturnNoContent() { var technologyList = new List <Technology>(); _mockRepository.Setup(m => m.FindAllAsync()).ReturnsAsync(technologyList); _mockEntityRepository.Setup(m => m.FindAllAsync()).ReturnsAsync(new List <Entity>() { }); var technologyService = new TechnologyService(); var result = await _controller.GetAllTechnologies(_mockRepository.Object, _mockEntityRepository.Object, technologyService); Assert.IsAssignableFrom <NoContentResult>(result); }
public HttpResponseMessage UpdateTechnology(Technology TechnologyModal) { if (ModelState.IsValid) { TechnologyService service = new TechnologyService(); TechnologyModal.UpdatedBy = this.Request.Headers.GetValues("username").First(); service.UpdateTechnology(TechnologyModal); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, "updated technology details sucessfully"); return(response); } else { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)); } }
public void SetEntityStatusWithEmptyEntityTechnologiesShouldNotModifyEntitiesStatus() { var technologyService = new TechnologyService(); var technology = new Technology("C++", "c++", "Languages and Frameworks", "", ""); var entity = new Entity() { Name = "1", Id = "5c73c15a8b89521e44e98804", Technologies = new EntityTechnology[0] }; var newTechnology = technologyService.SetEntityStatus(technology, entity, "id"); Assert.Equal(technology.EntitiesStatus, newTechnology.EntitiesStatus); }
public void SetEntityStatusShouldUpdateTechnologyGroupStatus() { var technologyService = new TechnologyService(); var technology = new Technology("C++", "c++", "Languages and Frameworks", "", ""); var entity = new Entity() { Name = "1", Id = "5c73c15a8b89521e44e98804", Technologies = new EntityTechnology[] { new EntityTechnology(technology.Id, "Status", new EntityTechnologyUrl[0]), } }; var newTechnology = technologyService.SetEntityStatus(technology, entity, "5c73c15a8b89521e44e98804"); Assert.Equal("Status", newTechnology.GroupStatus); }
public async Task GetAllTechnologiesShouldReturnAllTechnologies() { var technologyList = new List <Technology>() { new Technology("C", "c", "Languages and Frameworks", "", ""), new Technology("C#", "c#", "Languages and Frameworks", "", ""), new Technology("C++", "c++", "Languages and Frameworks", "", "") }; technologyList[0].Id = "5c73c15a8b89521e44e98805"; technologyList[1].Id = "5c73c15a8b89521e44e98807"; var entityList = new List <Entity>() { new Entity() { Name = "1", Id = "5c73c15a8b89521e44e98804", Technologies = new EntityTechnology[] { new EntityTechnology("5c73c15a8b89521e44e98805", "Status", new EntityTechnologyUrl[0]), } }, new Entity() { Name = "1", Id = "5c73c15a8b89521e44e98806", Technologies = new EntityTechnology[] { new EntityTechnology("5c73c15a8b89521e44e98807", "Status", new EntityTechnologyUrl[0]), } }, new Entity() { Name = "1", Id = "5c73c15a8b89521e44e98808", Technologies = new EntityTechnology[0] }, }; _mockRepository.Setup(m => m.FindAllAsync()).ReturnsAsync(technologyList); _mockEntityRepository.Setup(m => m.FindAllAsync()).ReturnsAsync(entityList); var technologyService = new TechnologyService(); var result = await _controller.GetAllTechnologies(_mockRepository.Object, _mockEntityRepository.Object, technologyService) as OkObjectResult; var value = result.Value; Assert.IsAssignableFrom <IEnumerable <Technology> >(value); }
public ActionResult StartResearch(int technologyId) { var ts = new TechnologyService(); // Check for pending Research var pending = ts.GetCheckPendingResearch(this.UserContext.Id); ts.SaveChanges(); if (pending != null) { return(Json(new { success = false, message = string.Format("There is research currently pending ({0}) which must finish before starting new research.", pending.Technology.Name) }, JsonRequestBehavior.DenyGet)); } // Start Researching var response = ts.StartResearch(technologyId, this.UserContext.Id); if (response.IsSuccessful) { ts.SaveChanges(); } return(Json(new { success = response.IsSuccessful, message = response.Messages["Message"].ToString() }, JsonRequestBehavior.DenyGet)); }
// GET: Dashboard public ActionResult Index() { var vm = new DashboardViewModel(); var terr = this.UserContext.Territory; vm.TerritoryName = terr.Name; vm.OutskirtsAppeal = "Good"; vm.Resources.Add(new ResourceSkinny { Name = "Water", Count = this.UserContext.Items.Single(x => x.ItemId == (int)ResourceTypes.Water).Quantity, Allocation = terr.WaterAllocation }); vm.Resources.Add(new ResourceSkinny { Name = "Food", Count = this.UserContext.Items.Single(x => x.ItemId == (int)ResourceTypes.Food).Quantity, Allocation = terr.FoodAllocation }); vm.Resources.Add(new ResourceSkinny { Name = "Wood", Count = this.UserContext.Items.Single(x => x.ItemId == (int)ResourceTypes.Wood).Quantity, Allocation = terr.WoodAllocation }); vm.Resources.Add(new ResourceSkinny { Name = "Stone", Count = this.UserContext.Items.Single(x => x.ItemId == (int)ResourceTypes.Stone).Quantity, Allocation = terr.StoneAllocation }); vm.Resources.Add(new ResourceSkinny { Name = "Oil", Count = this.UserContext.Items.Single(x => x.ItemId == (int)ResourceTypes.Oil).Quantity, Allocation = terr.OilAllocation }); vm.Resources.Add(new ResourceSkinny { Name = "Iron", Count = this.UserContext.Items.Single(x => x.ItemId == (int)ResourceTypes.Iron).Quantity, Allocation = terr.IronAllocation }); vm.CivilianPopulation = terr.CivilianPopulation; vm.TerritoryType = terr.Type; vm.TerritoryX = terr.X; vm.TerritoryY = terr.Y; vm.Neighbors = TerritoryService.GetNeighbors(this.UserContext.Territory) .Select(x => new TerritorySkinny { Direction = x.Key, TerritoryId = x.Value.TerritoryId, TerritoryName = x.Value.Name, }).ToList(); vm.RecentAttacks = this.Context.AttackLogs .Where(x => x.UserId == this.UserContext.Id) .OrderByDescending(x => x.TimeOfAttack) .Take(3) .Select(x => new AttackLogSkinny { Message = x.Message, WasAttacked = x.WasAttacked, TimeOfAttack = x.TimeOfAttack, }) .ToList(); // setup motd var storageAccount = CloudStorageAccount.Parse(System.Configuration.ConfigurationManager .ConnectionStrings["StorageConnectionString"].ConnectionString); var tableClient = storageAccount.CreateCloudTableClient(); var table = tableClient.GetTableReference("motd"); table.CreateIfNotExists(); var query = new TableQuery <MessageOfTheDayEntity>() .Where(TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, "motd")); var motd = table.ExecuteQuery(query) .OrderByDescending(x => x.Posted) .FirstOrDefault(); if (motd != null) { vm.MOTD = new Views.MOTD.Models.MOTDViewModel { Author = motd.Author, Message = motd.Message, Posted = motd.Posted, }; } var ts = new TechnologyService(); vm.CurrentlyReasearching = ts.GetCheckPendingResearch(this.UserContext.Id); ts.SaveChanges(); return(View(vm)); }