public bool Create(AreaCreateDTO req) { using (var db = new SqlSugarClient(Connection)) { bool result = true; R_Area model = new R_Area() { Name = req.Name, Description = req.Description, R_Restaurant_Id = req.Restaurant, ServerRate = req.ServerRate == null ? 0 : req.ServerRate }; if (db.Insert(model) == null) { result = false; } return(result); } }
public bool Update(AreaCreateDTO req) { using (var db = new SqlSugarClient(Connection)) { bool result = true; try { db.BeginTran(); R_Area model = new R_Area() { Name = req.Name, Description = req.Description, Id = req.Id, R_Restaurant_Id = req.Restaurant, ServerRate = req.ServerRate == null ? 0 : req.ServerRate }; db.Update(model); if (req.IsUpdate) { db.Update <R_Table>(new { ServerRate = model.ServerRate }, p => p.R_Area_Id == model.Id); } db.CommitTran(); } catch (Exception) { db.RollbackTran(); result = false; } return(result); } }