public IActionResult AddMoon(IFormFile Photo, string Name, string Galaxy, uint Radius, uint Temperature, DateTime Date, string Pl, uint Dist, string Unit) { byte[] ph = new byte[0]; if (Photo != null) { var str = Photo.OpenReadStream(); ph = new byte[str.Length]; str.Read(ph, 0, ph.Length); str.Close(); } var xml = new XmlSerializer(typeof(List <DBMoon>)); var stream = new MemoryStream(HttpContext.Session.Get("moons")); var moons = xml.Deserialize(stream) as List <DBMoon>; var moon = new DBMoon(Date, ph, Name, new Distance(Dist, StringToUnit(Unit)), Radius, false, PlanetType.Gas, "", Galaxy, Temperature) { PlanetOwner = Pl }; moons.Add(moon); //moon.Id = -1; SaveToSession(moons, xml, "moons"); HttpContext.Session.Set("img", ph); HttpContext.Session.Set("imgflag", new byte[1] { 1 }); return(View("~/Views/Views/MoonView.cshtml", moon)); }
public IActionResult ChangeMoon(IFormFile Photo, string Name, string Galaxy, uint Radius, uint Temperature, DateTime Date, string Pl, uint Dist, string Unit, int Id, int PlanetId) { byte[] ph = new byte[0]; if (Photo != null) { var str = Photo.OpenReadStream(); ph = new byte[str.Length]; str.Read(ph, 0, ph.Length); str.Close(); } var moon = new DBMoon(Date, ph, Name, new Distance(Dist, StringToUnit(Unit)), Radius, false, PlanetType.Gas, "", Galaxy, Temperature) { PlanetOwner = Pl, Id = Id, PlanetId = PlanetId }; HttpContext.Session.Set("img", ph); HttpContext.Session.Set("imgflag", new byte[1] { 1 }); db.Entry(moon).State = EntityState.Modified; db.SaveChanges(); return(View("~/Views/Views/MoonView.cshtml", moon)); }
private static void PrintMoons(DBStar star, ISheet sheet, int i, IRow row, int j, ICell cell, DBMoon moon) { row = sheet.GetRow(i); cell = row.GetCell(j); cell.SetCellValue(moon.Name); cell = row.GetCell(j + 1) ?? row.CreateCell(j + 1); cell.SetCellValue(moon.MiddleDistanceValue + moon.MiddleDistanceUnit.ToString()); cell = row.GetCell(j + 2) ?? row.CreateCell(j + 2); cell.SetCellValue(moon.Radius); cell = row.GetCell(j + 3) ?? row.CreateCell(j + 3); cell.SetCellValue(moon.PlanetOwner); cell = row.GetCell(j + 4) ?? row.CreateCell(j + 4); cell.SetCellValue(moon.Temperature); cell = row.GetCell(j + 5) ?? row.CreateCell(j + 5); cell.SetCellValue(moon.InventingDate); cell.CellStyle.DataFormat = 14; cell = row.GetCell(j + 6) ?? row.CreateCell(j + 6); cell.SetCellValue(moon.HasAtmosphere); /* * if (planet != star.Planets.Last()) * row = sheet.CopyRow(i, i + 1);*/ }