public void New(RiceModel model) { var sql = @"INSERT INTO rice(name,avgyield,maxyield,maturity,height,grainsize, millingrecovery,eatingquality,notes, growthstage1, growthstage2,growthstage3,growthstage4,growthstage5) VALUES (@name,@avgyield,@maxyield,@maturity,@height,@grainsize, @millingrecovery,@eatingquality,@notes, @growthstage1, @growthstage2,@growthstage3,@growthstage4,@growthstage5) SELECT CAST(SCOPE_IDENTITY() AS int)"; var id = db.Query <int>(sql, new { model.Name, model.AvgYield, model.MaxYield, model.Maturity, model.Height, model.GrainSize, model.MillingRecovery, model.EatingQuality, model.Notes, model.GrowthStage1, model.GrowthStage2, model.GrowthStage3, model.GrowthStage4, model.GrowthStage5 }).Single(); model.Id = id; }
public IActionResult Save(RiceModel item) { if (item.Id == 0) { _model.New(item); } else { _model.Update(item); } return(View("Index", _model.GetAll())); }
public void New(RiceModel model) { var sql = @"INSERT INTO rice(name,minrainfall,maxrainfall,mintemperature,maxtemperature,maturity,soiltype) VALUES (@name,@minrainfall,@maxrainfall,@mintemperature,@maxtemperature,@maturity,@soiltype) SELECT CAST(SCOPE_IDENTITY() AS int)"; var id = db.Query <int>(sql, new { model.Name, model.MinRainfall, model.MaxRainfall, model.MinTemperature, model.MaxTemperature, model.Maturity, model.SoilType }).Single(); model.Id = id; }
async Task postLocationAsync() { var locator = CrossGeolocator.Current; locator.DesiredAccuracy = 50; var position = await locator.GetPositionAsync(TimeSpan.FromMilliseconds(1000)); RiceModel model = new RiceModel() { Longitude = (float)position.Longitude, Latitude = (float)position.Latitude }; await AzureManager.AzureManagerInstance.PostRiceInformation(model); }
public void Update(RiceModel model) { var sql = @"UPDATE rice SET name = @name, minrainfall = @minrainfall, maxrainfall = @maxrainfall, mintemperature = @mintemperature, maxtemperature = @maxtemperature, maturity = @maturity, soiltype = @soiltype WHERE id = @id"; db.Execute(sql, new { model.Name, model.MinRainfall, model.MaxRainfall, model.MinTemperature, model.MaxTemperature, model.Maturity, model.SoilType, model.Id }); }
public void Update(RiceModel model) { var sql = @"UPDATE rice SET name = @name, avgyield = @avgyield, maxyield = @maxyield, maturity = @maturity, height = @height, grainsize = @grainsize, millingrecovery = @millingrecovery, eatingquality = @eatingquality, notes = @notes, growthstage1 = @growthstage1, growthstage2 = @growthstage2, growthstage3 = @growthstage3, growthstage4 = @growthstage4, growthstage5 = @growthstage5 WHERE id = @id"; db.Execute(sql, new { model.Name, model.AvgYield, model.MaxYield, model.Maturity, model.Height, model.GrainSize, model.MillingRecovery, model.EatingQuality, model.Notes, model.GrowthStage1, model.GrowthStage2, model.GrowthStage3, model.GrowthStage4, model.GrowthStage5, model.Id }); }
public async Task DeleteRiceInformation(RiceModel RiceModel) { await this.RiceTable.DeleteAsync(RiceModel); }
public async Task PostRiceInformation(RiceModel RiceModel) { await this.RiceTable.InsertAsync(RiceModel); }
public IActionResult New() { var item = new RiceModel(); return(View("Form", item)); }
private RiceModel GetMenu() { RiceModel riceModel = new RiceModel(); List <RiceMenu> Menus = new List <RiceMenu> { new RiceMenu { Category = "便當", Name = "雞腿飯", Price = 100 }, new RiceMenu { Category = "便當", Name = "排骨飯", Price = 90 }, new RiceMenu { Category = "便當", Name = "蝦排飯", Price = 90 }, new RiceMenu { Category = "炒飯", Name = "肉絲炒飯", Price = 60 }, new RiceMenu { Category = "炒飯", Name = "火腿炒飯", Price = 60 }, new RiceMenu { Category = "炒飯", Name = "牛肉炒飯", Price = 90 }, new RiceMenu { Category = "炒飯", Name = "蝦仁炒飯", Price = 80 }, new RiceMenu { Category = "湯麵", Name = "切仔麵", Price = 60 }, new RiceMenu { Category = "湯麵", Name = "烏龍麵", Price = 70 }, new RiceMenu { Category = "湯麵", Name = "乾麵", Price = 30 } }; riceModel.Menus = Menus; return(riceModel); }