void Awake() { if (Instance == null) { Instance = this; } else if (Instance != this) { Destroy(gameObject); } DontDestroyOnLoad(gameObject); BoostController = new BoostController(_boostView); MoneyController = new MoneyController(_moneyView, BoostController); ShopController = new ShopController(_listOfBoosts, _shopView); ManagerController = new ManagerController(_listOfManagers, _managerView); if (_useClearSavegame) { PlayerPrefs.SetFloat("money", 3000); } float oldMoney = PlayerPrefs.GetFloat("money"); MoneyController.AddMoney(oldMoney); }
public void ProductionController_CreateProductionDateTime_Pass() { // Arrange var dbcontext = new BroadwayBuilderContext(); var theaterService = new TheaterService(dbcontext); var theater = new Theater() { TheaterName = "Some Theater 1", StreetAddress = "Theater St", State = "CA", City = "LA", CompanyName = "Regal", Country = "US", PhoneNumber = "123456789" }; theaterService.CreateTheater(theater); dbcontext.SaveChanges(); var production = new Production() { ProductionName = "The Lion King 2", DirectorFirstName = "Jane", DirectorLastName = "Doe", Street = "Anahiem", City = "Long Beach", StateProvince = "California", Country = "United States", Zipcode = "919293", TheaterID = theater.TheaterID }; var productionService = new ProductionService(dbcontext); productionService.CreateProduction(production); dbcontext.SaveChanges(); var date = DateTime.Parse("3/23/2019 3:22:29 PM"); var time = TimeSpan.Parse("10:30:00"); var productionDateTime = new ProductionDateTime(production.ProductionID, date, time); var productionController = new ProductionController(); // Act var actionResult = productionController.CreateProductionDateTime(production.ProductionID, productionDateTime); var response = actionResult as OkNegotiatedContentResult <string>; productionService.DeleteProductionDateTime(productionDateTime); dbcontext.SaveChanges(); productionService.DeleteProduction(production.ProductionID); dbcontext.SaveChanges(); theaterService.DeleteTheater(theater); dbcontext.SaveChanges(); // Assert Assert.IsNotNull(response); Assert.AreEqual("Production Date and time have been added!", response.Content); }
// Start is called before the first frame update void Start() { p1Production = island1.GetComponentInChildren <ProductionController>(); p2Production = island2.GetComponentInChildren <ProductionController>(); p1WaterLevel = island1.GetComponent <WaterLevelController>(); p2WaterLevel = island2.GetComponent <WaterLevelController>(); musicController = GetComponent <MusicController>(); }
public void ProductionController_DeleteProduction_Pass() { // Arrange var dbcontext = new BroadwayBuilderContext(); var theaterService = new TheaterService(dbcontext); var theater = new Theater() { TheaterName = "Some Theater", StreetAddress = "Theater St", State = "CA", City = "LA", CompanyName = "Regal", Country = "US", PhoneNumber = "123456789" }; theaterService.CreateTheater(theater); dbcontext.SaveChanges(); var productionService = new ProductionService(dbcontext); var production = new Production { ProductionName = "The Pajama Game", DirectorFirstName = "Doris", DirectorLastName = "Day", City = "San Diego", StateProvince = "California", Country = "U.S", TheaterID = theater.TheaterID, Street = "123 Sesame St", Zipcode = "91911" }; productionService.CreateProduction(production); dbcontext.SaveChanges(); var productionController = new ProductionController(); // Act var actionResult = productionController.deleteProduction(production.ProductionID); var response = actionResult as OkNegotiatedContentResult <string>; var dbcontext_ = new BroadwayBuilderContext(); var theaterService_ = new TheaterService(dbcontext_); var theater_ = theaterService.GetTheaterByID(theater.TheaterID); theaterService_.DeleteTheater(theater_); dbcontext_.SaveChanges(); // Assert Assert.IsNotNull(response); Assert.AreEqual("Production deleted succesfully", response.Content); }
// Use this for initialization void Start() { DontDestroyOnLoad(this.gameObject); productsOnWork.Clear(); checkTaskState = false; if (instance == null) { instance = this; } }
public Program() { Runtime.UpdateFrequency = UpdateFrequency.Update1; commandRouter = new CommandRouter(this); airlockController = new AirlockController(this); leakController = new LeakController(this); productionController = new ProductionController(this); screenManager = new ScreenManager(this); Configure(); }
public async Task Production_GetProductAsync() { // Arrange var controller = new ProductionController(AdventureWorksRepository); // Act var response = await controller.GetProduct(1) as ObjectResult; // Assert var value = response.Value as ISingleModelResponse <ProductViewModel>; Assert.False(value.DidError); }
public void ReadInput(InputField inputField) { if (inputField.gameObject.name.Equals("inputTerminal")) { ProductionController.CheckTerminal(inputField.text); } else if (inputField.gameObject.name.Equals("inputNoTerminal")) { ProductionController.CheckNoTerminal(inputField.text); } inputField.text = ""; }
public ProductionControllerTest() { _faker = new Faker(); _areaService = new Mock <IAreaService>(); _mapper = new Mock <IMapper>(); _productionController = new ProductionController(_areaService.Object, _mapper.Object); _areasModel = new AreasModel { On = _faker.Random.Bool(), ProductionId = _faker.Random.Guid(), Restrictions = Enumerable.Range(2, 5) .Select(_ => _faker.Name.FirstName()) .ToList() }; }
public async Task TestGetProductSubcategoriesAsync() { using (var repository = RepositoryMocker.GetProductionRepository()) { // Arrange var controller = new ProductionController(repository); // Act var response = await controller.GetProductSubcategories() as ObjectResult; // Assert var value = response.Value as IListResponse <ProductSubcategoryViewModel>; Assert.False(value.DidError); } }
public async Task TestGetProductsAsync() { // Arrange var repository = RepositoryMocker.GetAdventureWorksRepository(); var controller = new ProductionController(repository, null); // Act var response = await controller.GetProductsAsync() as ObjectResult; var value = response.Value as IListModelResponse <ProductViewModel>; controller.Dispose(); // Assert Assert.False(value.DidError); }
public async Task GetProductsTestAsync() { // Arrange var productionBusinessObject = BusinessObjectMocker.GetProductionBusinessObject(); using (var controller = new ProductionController(null, productionBusinessObject)) { // Act var response = await controller.GetProductsAsync() as ObjectResult; // Assert var value = response.Value as IListModelResponse <Product>; Assert.False(value.DidError); } }
public async Task Production_GetProductsAsync() { using (var repository = RepositoryMocker.AdventureWorksRepository) { // Arrange var controller = new ProductionController(repository); // Act var response = await controller.GetProducts() as ObjectResult; // Assert var value = response.Value as IListModelResponse <ProductViewModel>; Assert.False(value.DidError); } }
public async Task GetProductsTestAsync() { // Arrange var logger = LoggerMocker.GetLogger <ProductionController>(); var productionService = ServiceMocker.GetProductionService(); using (var controller = new ProductionController(logger, productionService)) { // Act var response = await controller.GetProductsAsync() as ObjectResult; var value = response.Value as IPagedResponse <Product>; // Assert Assert.False(value.DidError); } }
public async Task TestGetNonExistingProductAsync() { // Arrange var repository = RepositoryMocker.GetAdventureWorksRepository(); var controller = new ProductionController(repository); var id = 0; // Act var response = await controller.GetProductAsync(id) as ObjectResult; var value = response.Value as ISingleModelResponse <ProductViewModel>; repository.Dispose(); // Assert Assert.False(value.DidError); }
public async Task Production_DeleteProductAsync() { using (var repository = RepositoryMocker.AdventureWorksRepository) { // Arrange var controller = new ProductionController(repository); var id = 1000; // Act var response = await controller.DeleteProduct(id) as ObjectResult; // Assert var value = response.Value as ISingleModelResponse <ProductViewModel>; Assert.False(value.DidError); } }
public async Task TestGetProductsTestAsync() { // Arrange var logger = LogHelper.GetLogger <ProductionController>(); var productionService = ServiceMocker.GetProductionService(nameof(TestGetProductsTestAsync)); var controller = new ProductionController(logger, productionService); // Act var response = await controller.GetProductsAsync() as ObjectResult; var value = response.Value as IPagedResponse <Product>; controller.Dispose(); // Assert Assert.False(value.DidError); Assert.True(value.Model.Count() > 0); }
public async Task GetInventoryByProductTestAsync() { // Arrange var logger = LogHelper.GetLogger <ProductionController>(); var productionService = ServiceMocker.GetProductionService(); var id = 1; using (var controller = new ProductionController(logger, productionService)) { // Act var response = await controller.GetInventoryByProduct(id) as ObjectResult; var value = response.Value as IListResponse <ProductInventory>; // Assert Assert.False(value.DidError); } }
public async Task Production_CreateProductAsync() { // Arrange var controller = new ProductionController(AdventureWorksRepository); var viewModel = new ProductViewModel { ProductName = "New test product", ProductNumber = "ABCDE" }; // Act var response = await controller.CreateProduct(viewModel) as ObjectResult; // Assert var value = response.Value as ISingleModelResponse <ProductViewModel>; Assert.False(value.DidError); }
public async Task TestGetInventoryByProductTestAsync() { // Arrange var logger = LogHelper.GetLogger <ProductionController>(); var productionService = ServiceMocker.GetProductionService(nameof(TestGetInventoryByProductTestAsync)); var controller = new ProductionController(logger, productionService); var productID = 1; var warehouseID = "W0001"; // Act var response = await controller.GetProductInventoryAsync(productID, warehouseID) as ObjectResult; var value = response.Value as IListResponse <ProductInventory>; controller.Dispose(); // Assert Assert.False(value.DidError); Assert.True(value.Model.Count() > 0); }
public async Task TestPostProductAsync() { // Arrange var repository = RepositoryMocker.GetAdventureWorksRepository(); var controller = new ProductionController(repository, null); var request = new ProductViewModel { ProductName = String.Format("New test product {0}{1}{2}", DateTime.Now.Minute, DateTime.Now.Second, DateTime.Now.Millisecond), ProductNumber = String.Format("{0}{1}{2}", DateTime.Now.Minute, DateTime.Now.Second, DateTime.Now.Millisecond) }; // Act var response = await controller.PostProductAsync(request) as ObjectResult; var value = response.Value as ISingleModelResponse <ProductViewModel>; repository.Dispose(); // Assert Assert.False(value.DidError); }
// Start is called before the first frame update void Start() { p1Resources = islandA.GetComponentInChildren <ResourceController>(); p2Resources = islandB.GetComponentInChildren <ResourceController>(); p1Production = islandA.GetComponentInChildren <ProductionController>(); p2Production = islandB.GetComponentInChildren <ProductionController>(); seaLevel = GetComponent <SeaLevelController>(); musicController = GetComponent <MusicController>(); started = gameOver = false; turnActions = new List <Action> [turnLimit]; for (int i = 0; i < turnLimit; ++i) { turnActions[i] = new List <Action>(); } // Setup the first turn Clicked(); }
public async Task Production_CreateProductAsync() { using (var repository = RepositoryMocker.AdventureWorksRepository) { // Arrange var controller = new ProductionController(repository); var viewModel = new ProductViewModel { ProductName = String.Format("New test product {0}{1}{2}", DateTime.Now.Minute, DateTime.Now.Second, DateTime.Now.Millisecond), ProductNumber = String.Format("{0}{1}{2}", DateTime.Now.Minute, DateTime.Now.Second, DateTime.Now.Millisecond) }; // Act var response = await controller.CreateProduct(viewModel) as ObjectResult; // Assert var value = response.Value as ISingleModelResponse <ProductViewModel>; Assert.False(value.DidError); } }
public async Task Production_UpdateProductAsync() { using (var repository = RepositoryMocker.AdventureWorksRepository) { // Arrange var controller = new ProductionController(repository); var viewModel = new ProductViewModel { ProductID = 1, ProductName = "New product test II", ProductNumber = "XYZ" }; // Act var response = await controller.UpdateProduct(viewModel) as ObjectResult; // Assert var value = response.Value as ISingleModelResponse <ProductViewModel>; Assert.False(value.DidError); } }
public async Task TestPutProductAsync() { // Arrange var repository = RepositoryMocker.GetAdventureWorksRepository(); var controller = new ProductionController(repository, null); var id = 1; var request = new ProductViewModel { ProductID = id, ProductName = "New product test II", ProductNumber = "XYZ" }; // Act var response = await controller.UpdateProductAsync(id, request) as ObjectResult; var value = response.Value as ISingleModelResponse <ProductViewModel>; repository.Dispose(); // Assert Assert.False(value.DidError); }
public IndexTest() { productionService = new Mock <IProductionService>(); productionController = new ProductionController(productionService.Object); }
public string SaveProduction(DataTable dt) { string lblMessage = ""; ProductionController objCont = new ProductionController(); DataTable dtView = new DataTable(); string strViewQuery = "Select distinct * from vwMastersCode"; dtView = objQueryController.ExecuteQuery(strViewQuery); string sConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["connectionString"].ToString(); int rcount = 0; foreach (DataRow dr in dt.Rows) { ProductionUI objUI = new ProductionUI(); string strCause = "model"; int modelex = 1; int ProductionID = Convert.ToInt32(dr["ID"].ToString()); try { int flag = 0; string strMaterial = Convert.ToString(dr["Material"]); string strModelQuery = "Select * from ModelMapping where Material='" + strMaterial + "'"; DataTable dtModel = objQueryController.ExecuteQuery(strModelQuery); if (dtModel != null) { if (dtModel.Rows.Count > 0) { foreach (DataRow drModel in dtModel.Rows) { objUI.ModelMappingID = Convert.ToInt32(drModel["ID"].ToString()); strCause = strCause.Replace("model", ""); modelex = 0; flag++; } } } string strS = Convert.ToString(dr["S"]); if (strS == "") { objUI.S = Convert.ToInt16(null); } else { objUI.S = Convert.ToInt16(dr["S"]); } objUI.Material = Convert.ToString(dr["Material"]); objUI.SerialNo = Convert.ToString(dr["Serial no#"]); objUI.Plnt = Convert.ToString(dr["Plnt"]); string strSLoc = Convert.ToString(dr["SLoc"]); if (strSLoc == "") { objUI.SLoc = Convert.ToString(null); } else { objUI.SLoc = Convert.ToString(dr["SLoc"]); } objUI.Description = Convert.ToString(dr["Description of technical object"]); objUI.Production_Month = Convert.ToInt16(dr["Production_Month"]); objUI.Production_Month_Year = Convert.ToString(dr["Production_Month_Year"]); objUI.FromDate = Convert.ToDateTime(dr["FromDate"]); objUI.ToDate = Convert.ToDateTime(dr["ToDate"]); objUI.MonthID = Convert.ToInt16(dr["MonthID"]); objUI.YearID = Convert.ToInt16(dr["YearID"]); objUI.Quarter = Convert.ToString(dr["Quarter"]); if (flag == 1) { objCont.SaveProduction(objUI); rcount++; } else { string strQuery = "Insert into ProductionTemp ([S],[Material],[Serial no#],[Plnt],[SLoc],[Description of technical object],[Production_Month],[Model_Code],[Production_Month_Year],[IsApproved],MonthID,YearID,[Quarter],IsModelEx,FromDate,ToDate) "; strQuery += "Values ('" + dr["S"].ToString() + "','" + dr["Material"].ToString() + "','" + dr["Serial no."].ToString() + "','" + dr["Plnt"].ToString() + "','" + dr["SLoc"].ToString() + "','" + dr["Description of technical object"].ToString() + "','" + dr["Production_Month"].ToString() + "','" + dr["Model_Code"].ToString() + "','" + dr["Production_Month_Year"].ToString() + "',0,'" + dr["MonthID"].ToString() + "','" + dr["YearID"].ToString() + "','" + dr["Quarter"].ToString() + "','" + modelex + "','" + dr["FromDate"].ToString() + "','" + dr["ToDate"].ToString() + "')"; objQueryController.ExecuteQuery(strQuery); } lblMessage = "File Production saved successfully;No of Rows Affected:" + rcount; } catch { string strQuery = "Insert into ProductionTemp ([S],[Material],[Serial no#],[Plnt],[SLoc],[Description of technical object],[Production_Month],[Model_Code],[Production_Month_Year],[IsApproved],MonthID,YearID,[Quarter],IsModelEx,FromDate,ToDate) "; strQuery += "Values ('" + dr["S"].ToString() + "','" + dr["Material"].ToString() + "','" + dr["Serial no."].ToString() + "','" + dr["Plnt"].ToString() + "','" + dr["SLoc"].ToString() + "','" + dr["Description of technical object"].ToString() + "','" + dr["Production_Month"].ToString() + "','" + dr["Model_Code"].ToString() + "','" + dr["Production_Month_Year"].ToString() + "',0,'" + dr["MonthID"].ToString() + "','" + dr["YearID"].ToString() + "','" + dr["Quarter"].ToString() + "','" + modelex + "','" + dr["FromDate"].ToString() + "','" + dr["ToDate"].ToString() + "')"; objQueryController.ExecuteQuery(strQuery); } string strDeleteQuery = "Delete from ProductionTemp where [ID]=" + ProductionID; objQueryController.ExecuteQuery(strDeleteQuery); } return lblMessage; }
protected void btnUpdate_Click(object sender, EventArgs e) { DataTable dtProdMonth = new DataTable(); string strProdMonthQuery = "select * from ProductionMonth"; dtProdMonth = objQueryController.ExecuteQuery(strProdMonthQuery); DataTable dtView = new DataTable(); string strViewQuery = "Select distinct * from vwMastersCode"; dtView = objQueryController.ExecuteQuery(strViewQuery); //DataTable dtModel = new DataTable(); //string strModelQuery = "select * from Model"; //dtModel = objQueryController.ExecuteQuery(strModelQuery); ProductionController objCont = new ProductionController(); int rcount = 0; foreach (GridViewRow gr in grdProdException.Rows) { bool Discard = ((CheckBox)gr.FindControl("chkDiscard")).Checked; string str = ((HiddenField)gr.FindControl("hdnID")).Value; if (Discard == true) { string strDiscardQuery = "Delete from ProductionTemp where ID=" + Convert.ToInt16(str); objQueryController.ExecuteQuery(strDiscardQuery); string strQuery = "Select * from Productiontemp"; DataTable dt = new DataTable(); dt = objQueryController.ExecuteQuery(strQuery); grdProdException.DataSource = dt; grdProdException.DataBind(); } else { ProductionUI objUI = new ProductionUI(); int CurrentYearID = 0; int CurrentMonthID = 0; string strProductionMonthYear = ""; int modelex=1; string strQuarterYear = ""; string ProductionMonth = ""; try { string strS = Convert.ToString(((TextBox)gr.FindControl("txtS")).Text); if (strS == "") { objUI.S = Convert.ToInt32(null); } else { objUI.S = Convert.ToInt32(((TextBox)gr.FindControl("txtS")).Text); } objUI.Material = Convert.ToString(((TextBox)gr.FindControl("txtMaterial")).Text); objUI.SerialNo = Convert.ToString(((TextBox)gr.FindControl("txtSerialNo")).Text.Trim()); objUI.Plnt = Convert.ToString(((TextBox)gr.FindControl("txtPlnt")).Text); string strSLoc = Convert.ToString(((TextBox)gr.FindControl("txtSLoc")).Text); if (strSLoc == "") { objUI.SLoc = Convert.ToString(null); } else { objUI.SLoc = Convert.ToString(((TextBox)gr.FindControl("txtSLoc")).Text); } objUI.Description = Convert.ToString(((TextBox)gr.FindControl("txtDescription")).Text); string strSerialNo = Convert.ToString(((TextBox)gr.FindControl("txtSerialNo")).Text.Trim()); int serialnoLength = strSerialNo.Length; string ModelCode = "0"; if (serialnoLength == 11) //If Tractor No Length is 11 { ProductionMonth = strSerialNo.Substring(1, 2); // 2nd and 3rd digit is Production Month ModelCode = strSerialNo.Substring(3, 3); // The next 3 digits i.e. 4th, 5th and 6th digits is Model Code } else if (serialnoLength == 12) //If Tractor No Length is 12 { ProductionMonth = strSerialNo.Substring(1, 3); // 2nd to 4th digit is Production Month ModelCode = strSerialNo.Substring(4, 3); // The next 3 digits i.e. 5th, 6th and 7th digits is Model Code } //DataView dv = new DataView(dtModel); //dv.RowFilter = "Code =" + Convert.ToInt16(ModelCode); //DataTable dtModelCode = dv.ToTable(); //objUI.Production_Month = Convert.ToInt16(ProductionMonth); //try //{ // objUI.Model_Code = Convert.ToString(dtModelCode.Rows[0]["Model_Code"]); //} //catch //{ //} int flag = 0; //for (int i = 0; i < dtView.Rows.Count; i++) //{ // if ("model" == dtView.Rows[i]["tablename"].ToString() && Convert.ToString(ModelCode) == dtView.Rows[i]["code"].ToString()) // { // DataView dv = new DataView(dtModel); // dv.RowFilter = "Code ='" + Convert.ToString(ModelCode) + "'"; // DataTable dtModelCode = dv.ToTable(); // objUI.Model_Code = Convert.ToString(dtModelCode.Rows[0]["Model_Code"]); // //strCause = strCause.Replace("model", ""); // //modelex = 0; // flag++; // } //} string strMaterial = Convert.ToString(((TextBox)gr.FindControl("txtMaterial")).Text); string strModelQuery = "Select * from ModelMapping where Material='" + strMaterial + "'"; DataTable dtModel = objQueryController.ExecuteQuery(strModelQuery); if (dtModel != null) { if (dtModel.Rows.Count > 0) { foreach (DataRow drModel in dtModel.Rows) { objUI.ModelMappingID = Convert.ToInt32(drModel["ID"].ToString()); //strCause = strCause.Replace("model", ""); modelex = 0; flag++; } } } if (ProductionMonth != "") { int BaseProductionMonth = Convert.ToInt16(dtProdMonth.Rows[0]["BaseProductionMonth_Code"]); int BaseMonthID = Convert.ToInt16(dtProdMonth.Rows[0]["Month_ID"]); int BaseYearID = Convert.ToInt16(dtProdMonth.Rows[0]["Year_ID"]); string strBaseDate = Convert.ToString(BaseMonthID) + "/1/" + BaseYearID; DateTime BaseDate = Convert.ToDateTime(strBaseDate); int Offset = Convert.ToInt16(ProductionMonth) - BaseProductionMonth; DateTime ProdMonthYear = BaseDate.AddMonths(Offset); CurrentYearID = ProdMonthYear.Year; CurrentMonthID = ProdMonthYear.Month; string strCurrentYearID = (Convert.ToString(CurrentYearID)).Substring(2, 2); string strMonth = getMonth(CurrentMonthID); strProductionMonthYear = strMonth + "-" + strCurrentYearID; objUI.MonthID = CurrentMonthID; objUI.YearID = CurrentYearID; string strQuarter = ""; if (CurrentMonthID == 4 || CurrentMonthID == 5 || CurrentMonthID == 6) { strQuarter = "Q1"; } else if (CurrentMonthID == 7 || CurrentMonthID == 8 || CurrentMonthID == 9) { strQuarter = "Q2"; } else if (CurrentMonthID == 10 || CurrentMonthID == 11 || CurrentMonthID == 12) { strQuarter = "Q3"; } else if (CurrentMonthID == 1 || CurrentMonthID == 2 || CurrentMonthID == 3) { strQuarter = "Q4"; } if (CurrentMonthID < 4) { string strPreviousYearID = (Convert.ToString(CurrentYearID - 1)).Substring(2, 2); strCurrentYearID = strCurrentYearID.Replace("0", ""); strQuarterYear = strPreviousYearID + strCurrentYearID + strQuarter; } else { string strNextYearID = (Convert.ToString(CurrentYearID + 1)).Substring(2, 2); strNextYearID = strNextYearID.Replace("0", ""); strQuarterYear = strCurrentYearID + strNextYearID + strQuarter; } objUI.Quarter = strQuarterYear; objUI.Production_Month = Convert.ToInt32(ProductionMonth); objUI.Production_Month_Year = strProductionMonthYear; objUI.FromDate = Convert.ToDateTime(objUtility.ConvertDateTime(gr.Cells[6].Text)); objUI.ToDate = Convert.ToDateTime(objUtility.ConvertDateTime(gr.Cells[7].Text)); //string strProductionMonthYear = strMonth + "-" + strCurrentYearID; // objUI.Production_Month_Year = strProductionMonthYear; } if (flag == 1) { objCont.SaveProduction(objUI); rcount++; } else { string strQuery = "Insert into ProductionTemp ([Material],[Serial no#],[Plnt],[SLoc],[Description of technical object],[Production_Month],[Production_Month_Year],[IsApproved],MonthID,YearID,[Quarter],IsModelEx,FromDate,ToDate) "; strQuery += "Values ('" + ((TextBox)gr.FindControl("txtMaterial")).Text + "','" + ((TextBox)gr.FindControl("txtSerialNo")).Text + "','" + ((TextBox)gr.FindControl("txtPlnt")).Text + "','" + ((TextBox)gr.FindControl("txtSloc")).Text + "','" + ((TextBox)gr.FindControl("txtDescription")).Text + "','" + ProductionMonth + "','" + strProductionMonthYear + "','0','"+ CurrentMonthID +"','"+ CurrentYearID +"','"+ strQuarterYear +"','"+ modelex +"','" + Convert.ToDateTime(objUtility.ConvertDateTime(gr.Cells[6].Text)) + "','" + Convert.ToDateTime(objUtility.ConvertDateTime(gr.Cells[7].Text)) + "')"; objQueryController.ExecuteQuery(strQuery); } } catch { string strQuery = "Insert into ProductionTemp ([Material],[Serial no#],[Plnt],[SLoc],[Description of technical object],[Production_Month],[Production_Month_Year],[IsApproved],MonthID,YearID,[Quarter],IsModelEx,FromDate,ToDate) "; strQuery += "Values ('" + ((TextBox)gr.FindControl("txtMaterial")).Text + "','" + ((TextBox)gr.FindControl("txtSerialNo")).Text + "','" + ((TextBox)gr.FindControl("txtPlnt")).Text + "','" + ((TextBox)gr.FindControl("txtSloc")).Text + "','" + ((TextBox)gr.FindControl("txtDescription")).Text + "','" + ProductionMonth + "','" + strProductionMonthYear + "','0','" + CurrentMonthID + "','" + CurrentYearID + "','" + strQuarterYear + "','" + modelex + "','" + Convert.ToDateTime(objUtility.ConvertDateTime(gr.Cells[6].Text)) + "','" + Convert.ToDateTime(objUtility.ConvertDateTime(gr.Cells[7].Text)) + "')"; objQueryController.ExecuteQuery(strQuery); } string strDeleteQuery = "Delete from ProductionTemp where ID=" + Convert.ToInt16(str); objQueryController.ExecuteQuery(strDeleteQuery); string strGridQuery = "Select * from Productiontemp"; DataTable dt = new DataTable(); dt = objQueryController.ExecuteQuery(strGridQuery); grdProdException.DataSource = dt; grdProdException.DataBind(); } } }
public void ProductionController_UpdateProductionDateTime_Pass() { // Arrange var dbcontext = new BroadwayBuilderContext(); var theaterService = new TheaterService(dbcontext); var theater = new Theater() { TheaterName = "The Magicians", StreetAddress = "Pantene", State = "CA", City = "LA", CompanyName = "123 Sesame St", Country = "US", PhoneNumber = "123456789" }; theaterService.CreateTheater(theater); dbcontext.SaveChanges(); var productionService = new ProductionService(dbcontext); var production = new Production { ProductionName = "The Pajama Game 1", DirectorFirstName = "Doris", DirectorLastName = "Day", City = "San Diego", StateProvince = "California", Country = "U.S", TheaterID = theater.TheaterID, Street = "1234 Sesame St", Zipcode = "91911" }; productionService.CreateProduction(production); dbcontext.SaveChanges(); var date = DateTime.Parse("3/28/2019 3:22:29 PM"); var time = TimeSpan.Parse("11:30:00"); var productionDateTime = new ProductionDateTime(production.ProductionID, date, time); productionService.CreateProductionDateTime(production.ProductionID, productionDateTime); dbcontext.SaveChanges(); productionDateTime.Date = DateTime.Parse("3/27/2019 3:22:29 PM"); productionDateTime.Time = TimeSpan.Parse("9:30:00"); var productionController = new ProductionController(); // Act var actionResult = productionController.updateProductionDateTime(productionDateTime.ProductionDateTimeId, productionDateTime); var response = actionResult as OkNegotiatedContentResult <ProductionDateTime>; var updatedProductionDateTime = response.Content; var expected = new { DateTime = DateTime.Parse("3/27/2019 3:22:29 PM"), TimeSpan = TimeSpan.Parse("9:30:00") }; var actual = updatedProductionDateTime; productionService.DeleteProductionDateTime(productionDateTime); dbcontext.SaveChanges(); productionService.DeleteProduction(response.Content.ProductionID); dbcontext.SaveChanges(); theaterService.DeleteTheater(theater); dbcontext.SaveChanges(); // Assert Assert.IsNotNull(response); Assert.AreEqual(productionDateTime.ProductionDateTimeId, updatedProductionDateTime.ProductionDateTimeId); Assert.AreEqual(expected.DateTime, actual.Date); Assert.AreEqual(expected.TimeSpan, actual.Time); }
public void SaveProduction(DataTable dt) { ProductionController objCont = new ProductionController(); DataTable dtView = new DataTable(); string strViewQuery = "Select distinct * from vwMastersCode"; dtView = objQuerycontroller.ExecuteQuery(strViewQuery); DataTable dtModel = new DataTable(); string strModelQuery = "select * from Model"; dtModel = objQuerycontroller.ExecuteQuery(strModelQuery); int rcount = 0; foreach (DataRow dr in dt.Rows) { ProductionUI objUI = new ProductionUI(); string strCause = "model"; int modelex = 1; try { int flag = 0; for (int i = 0; i < dtView.Rows.Count; i++) { if ("model" == dtView.Rows[i]["tablename"].ToString() && dr["Model_Code"].ToString() == dtView.Rows[i]["code"].ToString()) { DataView dv = new DataView(dtModel); dv.RowFilter = "Code ='" + dr["Model_Code"].ToString() + "'"; DataTable dtModelCode = dv.ToTable(); objUI.Model_Code = Convert.ToString(dtModelCode.Rows[0]["Model_Code"]); strCause = strCause.Replace("model", ""); modelex = 0; flag++; } } string strS = Convert.ToString(dr["S"]); if (strS == "") { objUI.S = Convert.ToInt16(null); } else { objUI.S = Convert.ToInt16(dr["S"]); } objUI.Material = Convert.ToString(dr["Material"]); objUI.SerialNo = Convert.ToString(dr["Serial no#"]); objUI.Plnt = Convert.ToString(dr["Plnt"]); string strSLoc = Convert.ToString(dr["SLoc"]); if (strSLoc == "") { objUI.SLoc = Convert.ToString(null); } else { objUI.SLoc = Convert.ToString(dr["SLoc"]); } objUI.Description = Convert.ToString(dr["Description of technical object"]); objUI.Production_Month = Convert.ToInt16(dr["Production_Month"]); objUI.Production_Month_Year = Convert.ToString(dr["Production_Month_Year"]); //objUI.FromDate = CalProdfromDate.SelectedDate; //objUI.ToDate = CalProdtoDate.SelectedDate; objUI.FromDate = Convert.ToDateTime(dr["FromDate"]); objUI.ToDate = Convert.ToDateTime(dr["ToDate"]); objUI.MonthID = Convert.ToInt16(dr["MonthID"]); objUI.YearID = Convert.ToInt16(dr["YearID"]); objUI.Quarter = Convert.ToString(dr["Quarter"]); if (flag == 1) { objCont.SaveProduction(objUI); rcount++; } else { string strQuery = "Insert into ProductionTemp ([S],[Material],[Serial no#],[Plnt],[SLoc],[Description of technical object],[Production_Month],[Model_Code],[Production_Month_Year],[IsApproved],MonthID,YearID,[Quarter],IsModelEx,FromDate,ToDate) "; strQuery += "Values ('" + dr["S"].ToString() + "','" + dr["Material"].ToString() + "','" + dr["Serial no."].ToString() + "','" + dr["Plnt"].ToString() + "','" + dr["SLoc"].ToString() + "','" + dr["Description of technical object"].ToString() + "','" + dr["Production_Month"].ToString() + "','" + dr["Model_Code"].ToString() + "','" + dr["Production_Month_Year"].ToString() + "',0,'" + dr["MonthID"].ToString() + "','" + dr["YearID"].ToString() + "','" + dr["Quarter"].ToString() + "','" + modelex + "','" + dr["FromDate"].ToString() + "','" + dr["ToDate"].ToString() + "')"; objQuerycontroller.ExecuteQuery(strQuery); } } catch { string strQuery = "Insert into ProductionTemp ([S],[Material],[Serial no#],[Plnt],[SLoc],[Description of technical object],[Production_Month],[Model_Code],[Production_Month_Year],[IsApproved],MonthID,YearID,[Quarter],IsModelEx,FromDate,ToDate) "; strQuery += "Values ('" + dr["S"].ToString() + "','" + dr["Material"].ToString() + "','" + dr["Serial no#"].ToString() + "','" + dr["Plnt"].ToString() + "','" + dr["SLoc"].ToString() + "','" + dr["Description of technical object"].ToString() + "','" + dr["Production_Month"].ToString() + "','" + dr["Model_Code"].ToString() + "','" + dr["Production_Month_Year"].ToString() + "',0,'" + dr["MonthID"].ToString() + "','" + dr["YearID"].ToString() + "','" + dr["Quarter"].ToString() + "','" + modelex + "','" + dr["FromDate"].ToString() + "','" + dr["ToDate"].ToString() + "')"; objQuerycontroller.ExecuteQuery(strQuery); } } }
public void ProductionController_GetPhotos_Pass() { // Arrange var dbcontext = new BroadwayBuilderContext(); var theaterService = new TheaterService(dbcontext); var theater = new Theater() { TheaterName = "Some Theater", StreetAddress = "Theater St", State = "CA", City = "LA", CompanyName = "Regal", Country = "US", PhoneNumber = "123456789" }; theaterService.CreateTheater(theater); dbcontext.SaveChanges(); var productionService = new ProductionService(dbcontext); var production = new Production { ProductionName = "The Pajama Game", DirectorFirstName = "Doris", DirectorLastName = "Day", City = "San Diego", StateProvince = "California", Country = "U.S", TheaterID = theater.TheaterID, Street = "123 Sesame St", Zipcode = "91911" }; productionService.CreateProduction(production); dbcontext.SaveChanges(); var productionController = new ProductionController(); var mockPostedPdfFile1 = new MockPostedFile("jpg", 5000000, "1.jpg"); var mockPostedPdfFile2 = new MockPostedFile("jpg", 5000000, "2.jpg"); productionService.SavePhoto(production.ProductionID, mockPostedPdfFile1); productionService.SavePhoto(production.ProductionID, mockPostedPdfFile2); var currentDirectory = ConfigurationManager.AppSettings["FileDir"]; var dir = Path.Combine(currentDirectory, "Photos/"); var subdir = Path.Combine(dir, $"Production{production.ProductionID}/"); // Act var actionResult = productionController.GetPhotos(production.ProductionID); // Need access to contet of the response var response = actionResult as OkNegotiatedContentResult <List <string> >; var photoUrls = response.Content; var expected = true; var actual = false; if (photoUrls.Count == 2) { actual = true; } productionService.DeleteProduction(production.ProductionID); dbcontext.SaveChanges(); theaterService.DeleteTheater(theater); dbcontext.SaveChanges(); Directory.Delete(subdir, true); // Assert Assert.IsNotNull(response); Assert.AreEqual(expected, actual); }
/***********************************Function to Production Acr File into Sql Server 2000 using Bulk Copy Method***********************************/ public string SaveProduction(DataTable dt) { string lblMessage = ""; ProductionController objCont = new ProductionController(); DataTable dtView = new DataTable(); string strViewQuery = "Select distinct * from vwMastersCode"; dtView = objController.ExecuteQuery(strViewQuery); //DataTable dtModel = new DataTable(); //string strModelQuery = "select * from Model"; //dtModel = objController.ExecuteQuery(strModelQuery); DataTable dtMonthOC = new DataTable(); string strMonthOCQuery = "select * from MonthOpenClose"; dtMonthOC = objController.ExecuteQuery(strMonthOCQuery); DataView dvMonthOC = new DataView(dtMonthOC); DataTable dtFilter = new DataTable(); string[] strProdFromMonth = txtProdFromDate.Text.Trim().Split('/'); int FromMonth = Convert.ToInt16(strProdFromMonth[1]); //int FromMonth = CalProdfromDate.SelectedDate.Month; dvMonthOC.RowFilter = "MonthID =" + FromMonth; dtFilter = dvMonthOC.ToTable(); if (dtFilter.Rows != null) { bool OCStatus = Convert.ToBoolean(dtFilter.Rows[0]["Status"]); if (OCStatus == false) { lblMessage = "Month is Closed, Please open month to enter data"; } else { //int ToMonth = CalProdtoDate.SelectedDate.Month; string[] strToProdMonth = txtProdToDate.Text.Trim().Split('/'); int ToMonth = Convert.ToInt16(strToProdMonth[1]); string sConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["connectionString"].ToString(); //try //{ // string strDelete = "Delete from ProductionTemp"; // objController.ExecuteQuery(strDelete); // SqlConnection sqlconn = new SqlConnection(sConnectionString); // sqlconn.Open(); // SqlBulkCopy bulkCopy = new SqlBulkCopy(sqlconn); // bulkCopy.DestinationTableName = "ProductionTemp"; // bulkCopy.WriteToServer(dt); //} //catch //{ //} int rcount = 0; foreach (DataRow dr in dt.Rows) { ProductionUI objUI = new ProductionUI(); string strCause = "model"; int modelex = 1; try { int flag = 0; //for (int i = 0; i < dtView.Rows.Count; i++) //{ // if ("model" == dtView.Rows[i]["tablename"].ToString() && dr["Model_Code"].ToString() == dtView.Rows[i]["code"].ToString()) // { // DataView dv = new DataView(dtModel); // dv.RowFilter = "Code ='" + dr["Model_Code"].ToString() + "'"; // DataTable dtModelCode = dv.ToTable(); // objUI.Model_Code = Convert.ToString(dtModelCode.Rows[0]["Model_Code"]); // strCause = strCause.Replace("model", ""); // modelex = 0; // flag++; // } //} string strMaterial = Convert.ToString(dr["Material"]); string strModelQuery = "Select * from ModelMapping where Material='" + strMaterial + "'"; DataTable dtModel = objController.ExecuteQuery(strModelQuery); if (dtModel != null) { if (dtModel.Rows.Count > 0) { foreach (DataRow drModel in dtModel.Rows) { objUI.ModelMappingID = Convert.ToInt32(drModel["ID"].ToString()); strCause = strCause.Replace("model", ""); modelex = 0; flag++; } } } string strS = Convert.ToString(dr["S"]); if (strS == "") { objUI.S = Convert.ToInt16(null); } else { objUI.S = Convert.ToInt16(dr["S"]); } objUI.Material = Convert.ToString(dr["Material"]); objUI.SerialNo = Convert.ToString(dr["Serial no."]); objUI.Plnt = Convert.ToString(dr["Plnt"]); objUI.SLoc = Convert.ToString(dr["SLoc"]); objUI.Description = Convert.ToString(dr["Description of technical object"]); objUI.Production_Month = Convert.ToInt16(dr["Production_Month"]); objUI.Production_Month_Year = Convert.ToString(dr["Production_Month_Year"]); //objUI.FromDate = CalProdfromDate.SelectedDate; //objUI.ToDate = CalProdtoDate.SelectedDate; objUI.FromDate = Convert.ToDateTime(objUtility.ConvertDateTime(txtProdFromDate.Text.Trim())); objUI.ToDate = Convert.ToDateTime(objUtility.ConvertDateTime(txtProdToDate.Text.Trim())); objUI.MonthID = Convert.ToInt16(dr["MonthID"]); objUI.YearID = Convert.ToInt16(dr["YearID"]); objUI.Quarter = Convert.ToString(dr["Quarter"]); if (flag == 1) { objCont.SaveProduction(objUI); rcount++; } else { lnkProdException.Visible = true; string strQuery = "Insert into ProductionTemp ([S],[Material],[Serial no#],[Plnt],[SLoc],[Description of technical object],[Production_Month],[Model_Code],[Production_Month_Year],[IsApproved],MonthID,YearID,[Quarter],IsModelEx,FromDate,ToDate) "; strQuery += "Values ('" + dr["S"].ToString() + "','" + dr["Material"].ToString() + "','" + dr["Serial no."].ToString() + "','" + dr["Plnt"].ToString() + "','" + dr["SLoc"].ToString() + "','" + dr["Description of technical object"].ToString() + "','" + dr["Production_Month"].ToString() + "','" + dr["Model_Code"].ToString() + "','" + dr["Production_Month_Year"].ToString() + "',0,'" + dr["MonthID"].ToString() + "','" + dr["YearID"].ToString() + "','" + dr["Quarter"].ToString() + "','" + modelex + "','" + objUtility.ConvertDateTime(txtProdFromDate.Text.Trim()) + "','" + objUtility.ConvertDateTime(txtProdToDate.Text.Trim()) + "')"; objController.ExecuteQuery(strQuery); } lblMessage = "File Production saved successfully;No of Rows Affected:" + rcount; } catch { lnkProdException.Visible = true; string strQuery = "Insert into ProductionTemp ([S],[Material],[Serial no#],[Plnt],[SLoc],[Description of technical object],[Production_Month],[Model_Code],[Production_Month_Year],[IsApproved],MonthID,YearID,[Quarter],IsModelEx,FromDate,ToDate) "; strQuery += "Values ('" + dr["S"].ToString() + "','" + dr["Material"].ToString() + "','" + dr["Serial no."].ToString() + "','" + dr["Plnt"].ToString() + "','" + dr["SLoc"].ToString() + "','" + dr["Description of technical object"].ToString() + "','" + dr["Production_Month"].ToString() + "','" + dr["Model_Code"].ToString() + "','" + dr["Production_Month_Year"].ToString() + "',0,'" + dr["MonthID"].ToString() + "','" + dr["YearID"].ToString() + "','" + dr["Quarter"].ToString() + "','" + modelex + "','" + objUtility.ConvertDateTime(txtProdFromDate.Text.Trim()) + "','" + objUtility.ConvertDateTime(txtProdToDate.Text.Trim()) + "')"; objController.ExecuteQuery(strQuery); } } //string strAcrUpdateQuery = "UPDATE AcrBulk SET ModelMappingID =( SELECT Production.ModelMappingID FROM Production WHERE Production.SerialNo = Convert(varchar,AcrBulk.Tractor_No)) WHERE EXISTS ( SELECT Production.ModelMappingID FROM Production WHERE Production.SerialNo = Convert(varchar,AcrBulk.Tractor_No))"; string strAcrUpdateQuery = "Update AcrBulk set ModelMappingID = Production.ModelMappingID from AcrBulk inner join Production on Convert(varchar,AcrBulk.Tractor_No) = Production.SerialNo "; objController.ExecuteQuery(strAcrUpdateQuery); } } return lblMessage; }
private void InstantiateManagers() { conMan = new ConsumptionController(); proMan = new ProductionController(); traMan = new TradeController(); }
public string SaveProduction(DataTable dt) { string lblMessage = ""; ProductionController objCont = new ProductionController(); DataTable dtView = new DataTable(); string strViewQuery = "Select distinct * from vwMastersCode"; dtView = objQueryController.ExecuteQuery(strViewQuery); DataTable dtModel = new DataTable(); string strModelQuery = "select * from Model"; dtModel = objQueryController.ExecuteQuery(strModelQuery); string sConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["connectionString"].ToString(); //try //{ // string strDelete = "Delete from ProductionTemp"; // objController.ExecuteQuery(strDelete); // SqlConnection sqlconn = new SqlConnection(sConnectionString); // sqlconn.Open(); // SqlBulkCopy bulkCopy = new SqlBulkCopy(sqlconn); // bulkCopy.DestinationTableName = "ProductionTemp"; // bulkCopy.WriteToServer(dt); //} //catch //{ //} int rcount = 0; foreach (DataRow dr in dt.Rows) { ProductionUI objUI = new ProductionUI(); string strCause = "model"; int modelex = 1; try { int flag = 0; for (int i = 0; i < dtView.Rows.Count; i++) { if ("model" == dtView.Rows[i]["tablename"].ToString() && dr["Model_Code"].ToString() == dtView.Rows[i]["code"].ToString()) { DataView dv = new DataView(dtModel); dv.RowFilter = "Code ='" + dr["Model_Code"].ToString() + "'"; DataTable dtModelCode = dv.ToTable(); objUI.Model_Code = Convert.ToString(dtModelCode.Rows[0]["Model_Code"]); strCause = strCause.Replace("model", ""); modelex = 0; flag++; } } string strS = Convert.ToString(dr["S"]); if (strS == "") { objUI.S = Convert.ToInt32(null); } else { objUI.S = Convert.ToInt32(dr["S"]); } objUI.Material = Convert.ToString(dr["Material"]); objUI.SerialNo = Convert.ToString(dr["Serial no#"]); objUI.Plnt = Convert.ToString(dr["Plnt"]); string strSLoc = Convert.ToString(dr["SLoc"]); if (strSLoc == "") { objUI.SLoc = Convert.ToString(null); } else { objUI.SLoc = Convert.ToString(dr["SLoc"]); } objUI.Description = Convert.ToString(dr["Description of technical object"]); objUI.Production_Month = Convert.ToInt16(dr["Production_Month"]); objUI.Production_Month_Year = Convert.ToString(dr["Production_Month_Year"]); objUI.FromDate = Convert.ToDateTime(dr["FromDate"]); objUI.ToDate = Convert.ToDateTime(dr["ToDate"]); objUI.MonthID = Convert.ToInt16(dr["MonthID"]); objUI.YearID = Convert.ToInt16(dr["YearID"]); objUI.Quarter = Convert.ToString(dr["Quarter"]); if (flag == 1) { objCont.SaveProduction(objUI); rcount++; } else { string strQuery = "Insert into ProductionTemp ([S],[Material],[Serial no#],[Plnt],[SLoc],[Description of technical object],[Production_Month],[Model_Code],[Production_Month_Year],[IsApproved],MonthID,YearID,[Quarter],IsModelEx) "; strQuery += "Values ('" + dr["S"].ToString() + "','" + dr["Material"].ToString() + "','" + dr["Serial no#"].ToString() + "','" + dr["Plnt"].ToString() + "','" + dr["SLoc"].ToString() + "','" + dr["Description of technical object"].ToString() + "','" + dr["Production_Month"].ToString() + "','" + dr["Model_Code"].ToString() + "','" + dr["Production_Month_Year"].ToString() + "',0,'" + dr["MonthID"].ToString() + "','" + dr["YearID"].ToString() + "','" + dr["Quarter"].ToString() + "','" + modelex + "')"; objQueryController.ExecuteQuery(strQuery); } lblMessage = "File Production saved successfully;No of Rows Affected:" + rcount; } catch { string strQuery = "Insert into ProductionTemp ([S],[Material],[Serial no#],[Plnt],[SLoc],[Description of technical object],[Production_Month],[Model_Code],[Production_Month_Year],[IsApproved],MonthID,YearID,[Quarter],IsModelEx) "; strQuery += "Values ('" + dr["S"].ToString() + "','" + dr["Material"].ToString() + "','" + dr["Serial no#"].ToString() + "','" + dr["Plnt"].ToString() + "','" + dr["SLoc"].ToString() + "','" + dr["Description of technical object"].ToString() + "','" + dr["Production_Month"].ToString() + "','" + dr["Model_Code"].ToString() + "','" + dr["Production_Month_Year"].ToString() + "',0,'" + dr["MonthID"].ToString() + "','" + dr["YearID"].ToString() + "','" + dr["Quarter"].ToString() + "','" + modelex + "')"; objQueryController.ExecuteQuery(strQuery); } } return lblMessage; }
public StartCreatingProductsTest() { productionService = new Mock <IProductionService>(); productionController = new ProductionController(productionService.Object); }