private void DeleteGreenhouse(Control item) { var s = Greenhouse.ByID(Convert.ToInt32(((Literal)item.FindControl("litGreenhouseID")).Text)); s.Delete(); Bind(); }
public void MyTestInitialize() { greenhouse = new Greenhouse(); greenhouse.GreenhouseID = "UnitTesting"; greenhouse.IP = "127.0.0.1"; greenhouse.Password = "******"; greenhouse.Port = 8070; db.Greenhouses.Add(greenhouse); db.SaveChanges(); datalog = new Datalog(); datalog.Greenhouse_ID = greenhouse.GreenhouseID; datalog.TimeOfReading = DateTime.Now; datalog.InternalTemperature = 20; datalog.ExternalTemperature = 20; datalog.Humidity = 20; datalog.Waterlevel = 20; foreach (Datalog log in db.Datalogs) { if (log.Greenhouse_ID == datalog.Greenhouse_ID) { db.Datalogs.Remove(log); } } db.SaveChanges(); client = new ClientMock(greenhouse.IP, greenhouse.Port); client.ID = greenhouse.GreenhouseID; client.ListenForCommunication(); ServiceFacadeGetter.getInstance(); }
protected void changeStatusClick(object sender, EventArgs e) { Greenhouse oGHouse = new Greenhouse(); string gHouseID = Request.QueryString["Gid"].ToString(); gHouse = oGHouse.getGHouse(gHouseID); SqlConnection conn = new SqlConnection(constr); SqlCommand cmd = new SqlCommand("UPDATE GREENHOUSESTABLE SET STATUS = @STATUS WHERE GID = @GID", conn); if (gHouse.gHouse_Status == "Active") { cmd.Parameters.AddWithValue("@STATUS", "Inactive"); cmd.Parameters.AddWithValue("@GID", gHouse.gHouse_ID); } else { cmd.Parameters.AddWithValue("@STATUS", "Active"); cmd.Parameters.AddWithValue("@GID", gHouse.gHouse_ID); } conn.Open(); cmd.ExecuteNonQuery(); conn.Close(); Response.Redirect(Request.Url.AbsoluteUri); }
public ActionResult Greenhouse(int?id) { Greenhouse greenhouse = _db.Greenhouses.Include(g => g.Stock).Include(g => g.GetGreenhouseCategory).Include(g => g.PacksForGH).FirstOrDefault(g => g.Id == id); Stock stock = greenhouse.Stock; IEnumerable <Pack> packs = _db.Packs.Include(p => p.Stock).Where(p => p.Stock.Id == stock.Id); List <Pack> usepacks = new List <Pack>(); foreach (var p in packs) { usepacks.Add(p); } foreach (var p in packs) { foreach (var pfg in greenhouse.PacksForGH) { if (p.Name == pfg.Name) { var pp = usepacks.FirstOrDefault(u => u.Name == p.Name); usepacks.Remove(pp); } } } ViewBag.Categories = _db.GreenhouseCategories.Include(s => s.Stock).Where(c => c.Stock.Id == stock.Id).ToList(); ViewBag.Packs = usepacks; return(View(greenhouse)); }
public void MyTestInitialize() { greenhouseID = "UnitTesting"; greenhouse = new Greenhouse(); greenhouse.GreenhouseID = greenhouseID; greenhouse.IP = "127.0.0.1"; greenhouse.Password = "******"; greenhouse.Port = 8070; scheduleID = greenhouse.GreenhouseID + "Schedule"; db.Greenhouses.Add(greenhouse); db.SaveChanges(); foreach (Schedule block in db.Schedules) { if (block.ScheduleID == scheduleID) { db.Schedules.Remove(block); } } db.SaveChanges(); client = new ClientMock(greenhouse.IP, greenhouse.Port); client.ID = greenhouse.GreenhouseID; client.ListenForCommunication(); ServiceFacadeGetter.getInstance(); }
public ActionResult ContinuationAddClaim(int?id, int?idC) { Stock stock = _db.Stocks.Include(s => s.Packs).FirstOrDefault(s => s.Id == id); Claim claim = _db.Claims .Include(s => s.GreenhouseForSales) .FirstOrDefault(s => s.Id == idC); List <GreenhouseForSale> greenhouses = new List <GreenhouseForSale>(); List <Greenhouse> ngreenhouses = new List <Greenhouse>(); List <PackForGH> packs = new List <PackForGH>(); List <GreenHouseForList> lala = new List <GreenHouseForList>(); foreach (var gh in claim.GreenhouseForSales) { greenhouses.Add(gh); } foreach (var gh in greenhouses) { Greenhouse g1 = _db.Greenhouses.Include(g => g.PacksForGH).FirstOrDefault(g => g.Name == gh.Name && g.Stock.Id == stock.Id); ngreenhouses.Add(new Greenhouse() { Name = g1.Name, Group = g1.Group, Amount = gh.Amount, PacksForGH = g1.PacksForGH }); } ViewBag.Stock = stock; return(View(claim)); }
public void MergeFrom(ClientMapPoi other) { if (other == null) { return; } if (other.Id.Length != 0) { Id = other.Id; } if (other.Name.Length != 0) { Name = other.Name; } if (other.Latitude != 0D) { Latitude = other.Latitude; } if (other.Longitude != 0D) { Longitude = other.Longitude; } if (other.Description.Length != 0) { Description = other.Description; } if (other.PoiAccessibility != 0) { PoiAccessibility = other.PoiAccessibility; } switch (other.TypeCase) { case TypeOneofCase.Outpost: if (Outpost == null) { Outpost = new global::WUProtos.Data.Client.ClientMapOutpost(); } Outpost.MergeFrom(other.Outpost); break; case TypeOneofCase.Fortress: if (Fortress == null) { Fortress = new global::WUProtos.Data.Client.ClientMapFortress(); } Fortress.MergeFrom(other.Fortress); break; case TypeOneofCase.Greenhouse: if (Greenhouse == null) { Greenhouse = new global::WUProtos.Data.Client.ClientMapGreenhouse(); } Greenhouse.MergeFrom(other.Greenhouse); break; } _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); }
public ActionResult DeleteConfirmed(string id) { Greenhouse greenhouse = db.Greenhouses.Find(id); db.Greenhouses.Remove(greenhouse); db.SaveChanges(); return(RedirectToAction("Index")); }
public SettingsPage(Greenhouse greenhouse) { InitializeComponent(); this.greenhouse = greenhouse; UseSettings(); //pak image van database van deze arduino }
/// <summary> /// RealTime Constructor /// </summary> /// <param name="greenhouse"></param> public RealTime(Greenhouse greenhouse) { InitializeComponent(); this.greenhouse = greenhouse; rest = new ArdunoRestClient { BaseUrl = $"http://{greenhouse.Greenhouse_IP}/" }; SetTimer(); }
public ActionResult Edit([Bind(Include = "GreenhouseID,Password,IP,Port")] Greenhouse greenhouse) { if (ModelState.IsValid) { db.Entry(greenhouse).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(greenhouse)); }
public ActionResult Create([Bind(Include = "GreenhouseID,Password,IP,Port")] Greenhouse greenhouse) { if (ModelState.IsValid) { db.Greenhouses.Add(greenhouse); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(greenhouse)); }
static void Main(string[] args) { //new Building().Run(); //string lookFor = "Tools"; //Console.WriteLine("{0} found in area {1} ", lookFor, Search.FindItem(lookFor)); Greenhouse a = new Greenhouse(); a.Run(); Console.WriteLine("total cost is {0} ", a.calculateTotalCost()); }
public ChartPage(Greenhouse greenhouse) { InitializeComponent(); selectedGreenhouse = greenhouse; ChartTimeTable.ItemsSource = new List <string> { "Day", "Week", "Month", "Year" }; ChartWeekNumber.ItemsSource = Enumerable.Range(1, 52).ToList(); ChartMonthName.ItemsSource = new List <string> { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "Noveber", "December" }; }
public ActionResult Shipment(int?id, int?idS) { Stock stock = db.Stocks.Include(s => s.Packs).FirstOrDefault(s => s.Id == id); ViewBag.ColorS = stock.BackgroundColor; stock.Sales++; Sale sale = db.Sales.Include(s => s.Dealer).Include(s => s.GreenhouseForSales).FirstOrDefault(s => s.Id == idS); decimal sum = 0; List <GreenhouseForSale> greenhouses = new List <GreenhouseForSale>(); List <Greenhouse> ngreenhouses = new List <Greenhouse>(); List <PackForGH> packs = new List <PackForGH>(); List <GreenHouseForList> lala = new List <GreenHouseForList>(); sale.Number = stock.Prefix + stock.Sales.ToString(); db.SaveChanges(); foreach (var gh in sale.GreenhouseForSales) { greenhouses.Add(gh); } foreach (var gh in greenhouses) { Greenhouse g1 = db.Greenhouses.Include(g => g.PacksForGH).FirstOrDefault(g => g.Name == gh.Name && g.Stock.Id == stock.Id); ngreenhouses.Add(new Greenhouse() { Name = g1.Name, Group = g1.Group, Amount = gh.Amount, PacksForGH = g1.PacksForGH }); } foreach (var gh in ngreenhouses) { GreenHouseForList ghfl = new GreenHouseForList() { Name = gh.Name, Amount = gh.Amount }; foreach (var p in gh.PacksForGH) { sum = sum + p.Cost * p.Amount * gh.Amount; packs.Add(p); ghfl.Cost += p.Cost * p.Amount * gh.Amount; } lala.Add(ghfl); } ViewBag.Sum = sum; ViewBag.Stock = stock; ViewBag.GreenHouseList = lala; return(View(sale)); }
public ActionResult EditPositionForGreenhouse(int?id, int?group, string[] gh) { for (var i = 0; i < gh.Length; i++) { string buf = gh[i]; Greenhouse gh1 = _db.Greenhouses.Include(g => g.Stock) .FirstOrDefault(g => g.Stock.Id == id && g.Group == group && g.Name == buf); gh1.Position = i + 1; } _db.SaveChanges(); return(RedirectToAction("Index")); }
private void Bind() { if (User.IsInRole("administrator")) { LoadData(Greenhouse.All()); lbNewGreenhouse.Visible = true; } else { lbNewGreenhouse.Visible = false; LoadData(Greenhouse.AllByUsername(User.Identity.Name)); } }
// GET: Greenhouses/Delete/5 public ActionResult Delete(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Greenhouse greenhouse = db.Greenhouses.Find(id); if (greenhouse == null) { return(HttpNotFound()); } return(View(greenhouse)); }
public ActionResult Ticket(int?id) { Claim claim = db.Claims .Include(s => s.GreenhouseForSales) .Include(s => s.Stock) .FirstOrDefault(s => s.Id == id); List <PackForGH> packs = new List <PackForGH>(); foreach (var g in claim.GreenhouseForSales) { Greenhouse prod = db.Greenhouses .Include(x => x.PacksForGH) .Include(x => x.Stock) .FirstOrDefault(x => x.Name == g.Name && x.Stock.Id == claim.Stock.Id); foreach (var p in prod.PacksForGH) { decimal buf = p.Amount; p.Amount = p.Amount * g.Amount; if (p.Amount > 0) { PackForGH pfg = null; pfg = packs.FirstOrDefault(x => x.Name == p.Name); if (pfg == null) { packs.Add(new PackForGH() { Name = p.Name, Amount = p.Amount, Cost = p.Cost, GreenHouse = p.GreenHouse }); } else { pfg.Amount += p.Amount; } } p.Amount = buf; } } ViewBag.Packs = packs; return(View(claim)); }
public ActionResult GreenhouseDelete(int?id) { Greenhouse greenhouse = _db.Greenhouses.FirstOrDefault(g => g.Id == id); IEnumerable <PackForGH> packs = _db.PacksForGh.Where(p => p.GreenHouse.Id == id); foreach (var p in packs) { _db.PacksForGh.Remove(p); } _db.Greenhouses.Remove(greenhouse); _db.SaveChanges(); return(RedirectToAction("Index", "Admin")); }
public void MyTestInitialize() { greenhouse = new Greenhouse(); greenhouse.GreenhouseID = "UnitTesting"; greenhouse.IP = "127.0.0.1"; greenhouse.Password = "******"; greenhouse.Port = 8070; db.Greenhouses.Add(greenhouse); db.SaveChanges(); client = new ClientMock(greenhouse.IP, greenhouse.Port); client.ID = greenhouse.GreenhouseID; client.ListenForCommunication(); }
public override int GetHashCode() { int hash = 1; if (Id.Length != 0) { hash ^= Id.GetHashCode(); } if (Name.Length != 0) { hash ^= Name.GetHashCode(); } if (Latitude != 0D) { hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(Latitude); } if (Longitude != 0D) { hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(Longitude); } if (Description.Length != 0) { hash ^= Description.GetHashCode(); } if (typeCase_ == TypeOneofCase.Outpost) { hash ^= Outpost.GetHashCode(); } if (typeCase_ == TypeOneofCase.Fortress) { hash ^= Fortress.GetHashCode(); } if (typeCase_ == TypeOneofCase.Greenhouse) { hash ^= Greenhouse.GetHashCode(); } if (PoiAccessibility != 0) { hash ^= PoiAccessibility.GetHashCode(); } hash ^= (int)typeCase_; if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public static void ApplyLocation(IContentPack contentPack, Configs.Location location) { try { GameLocation loc; string mapPath = contentPack.GetActualAssetKey(location.FileName); switch (location.Type) { case "Cellar": loc = new Cellar(mapPath, location.MapName); break; case "BathHousePool": loc = new BathHousePool(mapPath, location.MapName); break; case "Decoratable": loc = new Locations.DecoratableLocation(mapPath, location.MapName); break; case "Desert": loc = new Locations.Desert(mapPath, location.MapName); break; case "Greenhouse": loc = new Greenhouse(mapPath, location.MapName); break; case "Sewer": loc = new Locations.Sewer(mapPath, location.MapName); break; default: loc = new GameLocation(mapPath, location.MapName); break; } loc.IsOutdoors = location.Outdoor; loc.IsFarm = location.Farmable; Game1.locations.Add(loc); } catch (Exception err) { ModEntry.Logger.ExitGameImmediately("Unable to add custom location, a unexpected error occured: " + location, err); } }
internal JObject fetchSchedule(string greenHouseID) { GreenhouseDBContext db = new GreenhouseDBContext(); Greenhouse greenhouse = new Greenhouse(); GreenhouseSchedule greenhouseSchedule = null; foreach (GreenhouseSchedule schedule in db.GreenhouseSchedules) { if (schedule.GreenhouseID == greenHouseID) { greenhouseSchedule = schedule; } } db.SaveChanges(); JObject jsonSchedule = new JObject(); JObject daySchedule = new JObject(); if (greenhouseSchedule != null) { foreach (GreenhouseWeb.Models.Schedule schedule in db.Schedules) { if (schedule.ScheduleID == greenhouseSchedule.ScheduleID) { JObject block = new JObject(); block.Add("temperature", schedule.InternalTemperature); block.Add("humidity", schedule.Humidity); block.Add("waterlevel", schedule.WaterLevel); block.Add("light_blue", schedule.BlueLight); block.Add("light_red", schedule.RedLight); daySchedule.Add("block" + schedule.Blocknumber, block); } } db.SaveChanges(); } jsonSchedule.Add("day1", daySchedule); jsonSchedule.Add("procedure", "applySchedule"); jsonSchedule.Add("days", 1); return(jsonSchedule); }
public ActionResult GreenHouse(int?id, Greenhouse model, int getgreenhousecategory) { Greenhouse greenhouse = _db.Greenhouses.Include(g => g.PacksForGH).Include(g => g.GetGreenhouseCategory).FirstOrDefault(g => g.Id == id); GreenhouseCategory category = _db.GreenhouseCategories.FirstOrDefault(c => c.Id == getgreenhousecategory); greenhouse.Name = model.Name; greenhouse.GetGreenhouseCategory = category; greenhouse.Bonus = model.Bonus; greenhouse.CostPrice = model.CostPrice; foreach (var p in greenhouse.PacksForGH) { foreach (var pp in model.PacksForGH) { if (p.Id == pp.Id) { p.Amount = pp.Amount; } } } foreach (var p in model.PacksForGH) { if (p.Amount == 0) { var i = greenhouse.PacksForGH.FirstOrDefault(pf => pf.Id == p.Id); greenhouse.PacksForGH.Remove(i); } } foreach (var p in model.Packs) { if (p.Amount != 0) { Pack pack = _db.Packs.FirstOrDefault(pck => pck.Id == p.Id); greenhouse.PacksForGH.Add(new PackForGH { Name = pack.Name, Cost = pack.Cost, Amount = p.Amount }); } } _db.SaveChanges(); return(RedirectToAction("Index", "Admin")); }
public ActionResult GreenhouseAdd(int?id, Greenhouse model, int?categoryId) { Stock stock = _db.Stocks.FirstOrDefault(s => s.Id == id); GreenhouseCategory category = _db.GreenhouseCategories.FirstOrDefault(c => c.Id == categoryId); List <PackForGH> packsForGH = new List <PackForGH>(); List <Pack> packs = new List <Pack>(); foreach (var p in model.Packs) { if (p.Amount != 0) { Pack pack = _db.Packs.FirstOrDefault(pck => pck.Id == p.Id); packsForGH.Add(new PackForGH { Name = pack.Name, Cost = pack.Cost, Amount = p.Amount }); packs.Add(pack); } } Greenhouse g1 = new Greenhouse() { Name = model.Name, GetGreenhouseCategory = category, Packs = packs, PacksForGH = packsForGH, Bonus = model.Bonus, CostPrice = model.CostPrice }; stock.Greenhouses.Add(g1); _db.SaveChanges(); return(RedirectToAction("GreenhouseList", "Admin", new { id = id })); }
internal void setIPAddress(string id, string ip, string port) { GreenhouseDBContext db = new GreenhouseDBContext(); Greenhouse greenhouse = new Greenhouse(); String password = ""; bool changes = true; foreach (Greenhouse item in db.Greenhouses) { if (item.GreenhouseID == id) { if (!(item.IP == ip && item.Port == int.Parse(port))) { password = item.Password; db.Greenhouses.Remove(item); } else { changes = false; } } } if (changes) { db.SaveChanges(); greenhouse.GreenhouseID = id; greenhouse.IP = ip; greenhouse.Port = int.Parse(port); greenhouse.Password = password; db.Greenhouses.Add(greenhouse); db.SaveChanges(); } }
//below as the Class methods for some DB operations. public Greenhouse getGHouse(string gHouseID) { Greenhouse gHouse_Detail = null; string gHouse_Name, gHouse_Status; int gHouse_Members; string queryStr = "SELECT * FROM GreenhousesTable WHERE Gid = @ProdID"; SqlConnection conn = new SqlConnection(_connStr); SqlCommand cmd = new SqlCommand(queryStr, conn); cmd.Parameters.AddWithValue("@ProdID", gHouseID); conn.Open(); SqlDataReader dr = cmd.ExecuteReader(); if (dr.Read()) { gHouse_Name = dr["Name"].ToString(); gHouse_Members = int.Parse(dr["Members"].ToString()); gHouse_Status = dr["Status"].ToString(); gHouse_Detail = new Greenhouse(gHouseID, gHouse_Name, gHouse_Members, gHouse_Status); } else { gHouse_Detail = null; } conn.Close(); dr.Close(); dr.Dispose(); return(gHouse_Detail); }
/// <summary> /// Save a Greenhouse /// </summary> /// <param name="greenhouse"></param> /// <returns>returns the id of the saved greenhouse</returns> public static int Save(Greenhouse greenhouse) { return Save(null, greenhouse); }
/// <summary> /// Save a Greenhouse /// </summary> /// <param name="dc"></param> /// <param name="greenhouse"></param> /// <returns>returns the id of the saved greenhouse</returns> public static int Save(DataContext dc, Greenhouse greenhouse) { return Repository.Save(dc, greenhouse); }
void Process_greenhouse(Greenhouse g, EnvironmentAnalyzer env, VesselAnalyzer va) { // skip disabled greenhouses if (!g.active) return; // shortcut to resources SimulatedResource ec = Resource("ElectricCharge"); SimulatedResource res = Resource(g.crop_resource); // calculate natural and artificial lighting double natural = env.solar_flux; double artificial = Math.Max(g.light_tolerance - natural, 0.0); // if lamps are on and artificial lighting is required if (artificial > 0.0) { // consume ec for the lamps ec.Consume(g.ec_rate * (artificial / g.light_tolerance), "greenhouse"); } // execute recipe SimulatedRecipe recipe = new SimulatedRecipe(g.part, "greenhouse"); foreach (ModuleResource input in g.resHandler.inputResources) { // WasteAtmosphere is primary combined input if (g.WACO2 && input.name == "WasteAtmosphere") recipe.Input(input.name, env.breathable ? 0.0 : input.rate, "CarbonDioxide"); // CarbonDioxide is secondary combined input else if (g.WACO2 && input.name == "CarbonDioxide") recipe.Input(input.name, env.breathable ? 0.0 : input.rate, ""); // if atmosphere is breathable disable WasteAtmosphere / CO2 else if (!g.WACO2 && (input.name == "CarbonDioxide" || input.name == "WasteAtmosphere")) recipe.Input(input.name, env.breathable ? 0.0 : input.rate, ""); else recipe.Input(input.name, input.rate); } foreach (ModuleResource output in g.resHandler.outputResources) { // if atmosphere is breathable disable Oxygen if (output.name == "Oxygen") recipe.Output(output.name, env.breathable ? 0.0 : output.rate, true); else recipe.Output(output.name, output.rate, true); } recipes.Add(recipe); // determine environment conditions bool lighting = natural + artificial >= g.light_tolerance; bool pressure = va.pressurized || g.pressure_tolerance <= double.Epsilon; bool radiation = (env.landed ? env.surface_rad : env.magnetopause_rad) * (1.0 - va.shielding) < g.radiation_tolerance; // if all conditions apply // note: we are assuming the inputs are satisfied, we can't really do otherwise here if (lighting && pressure && radiation) { // produce food res.Produce(g.crop_size * g.crop_rate, "greenhouse"); // add harvest info res.harvests.Add(Lib.BuildString(g.crop_size.ToString("F0"), " in ", Lib.HumanReadableDuration(1.0 / g.crop_rate))); } }
/// <summary> /// Delete a single greenhouse /// </summary> /// <param name="greenhouse"></param> public static void Delete(Greenhouse greenhouse) { Delete(null, greenhouse); }
public ActionResult ShipmentConfirmM(int?id) { Sale sale = db.Sales .Include(s => s.Dealer) .Include(s => s.Stock) .Include(s => s.GreenhouseForSales) .FirstOrDefault(s => s.Id == id); Stock stock = db.Stocks.FirstOrDefault(s => s.Id == sale.Stock.Id); sale.Confirmed = true; //Увеличивает задолжность дилера, если есть необходимость и дилер if (sale.Remain > 0 && sale.Dealer != null) { Dealer d1 = db.Dealers.FirstOrDefault(d => d.Name == sale.Dealer.Name); d1.Debt += sale.Remain; } //Списывает пакеты со склада, если была отгрузка if (sale.Shipment == true) { foreach (var g in sale.GreenhouseForSales) { Greenhouse g1 = db.Greenhouses .Include(gh => gh.PacksForGH) .Include(gh => gh.Stock) .FirstOrDefault(gh => gh.Name == g.Name && gh.Stock.Id == stock.Id); foreach (var p in g1.PacksForGH) { Pack p1 = db.Packs .Include(pck => pck.Stock) .FirstOrDefault(pck => pck.Name == p.Name && pck.Stock.Id == stock.Id); p1.Amount -= 1 * p.Amount * g.Amount; HistoryPack hp1 = new HistoryPack() { Name = p1.Name, Amount = p.Amount * g.Amount * -1, Date = DateTime.Now, ForHistory = false, Sale = sale, Pack = p1, Stock = stock, Description = sale.Number }; db.HistoryPacks.Add(hp1); } } } foreach (var g in sale.GreenhouseForSales) { Greenhouse g1 = db.Greenhouses .Include(gh => gh.PacksForGH) .Include(gh => gh.Stock) .FirstOrDefault(gh => gh.Name == g.Name && gh.Stock.Id == stock.Id); sale.SumBonuses += (g1.Bonus * g.Amount); sale.SumCostPrice += (g1.CostPrice * g.Amount); sale.Profit = sale.SumWithD - sale.SumCostPrice; } InfoMoney im1 = null; im1 = db.InfoMoneys.Include(i => i.Sale).FirstOrDefault(i => i.Sale.Id == sale.Id); if (im1 == null) { im1 = new InfoMoney() { Stock = stock, Sale = sale, Cost = sale.AddMoney, Date = DateTime.UtcNow.AddHours(6), PayForTerminal = sale.PayForTerminal }; db.InfoMoneys.Add(im1); } else { im1.Stock = stock; im1.Sale = sale; im1.Cost = sale.AddMoney; im1.Date = DateTime.UtcNow.AddHours(6); im1.PayForTerminal = sale.PayForTerminal; } db.SaveChanges(); HttpCookie cookie = Request.Cookies["Greenhouses"]; cookie["ListForRealization"] = null; Response.Cookies.Add(cookie); return(RedirectToAction("Index", "Production", new { id = sale.Id })); }
/// <summary> /// Delete a single greenhouse /// </summary> /// <param name="dc"></param> /// <param name="greenhouse"></param> public static void Delete(DataContext dc, Greenhouse greenhouse) { Repository.Delete(dc, greenhouse); }