private void SaveDB(VTurbine model) { DTurbine db; var now = DateTime.UtcNow; if (model.Id == Guid.Empty) { db = new DTurbine(); db.Id = Guid.NewGuid(); db.Created = now; db.Author = HttpContext.User.Identity.Name; model.Id = db.Id; _ctx.DTurbines.AddObject(db); } else { db = _ctx.DTurbines.First(n => n.Id == model.Id); } db.Updated = now; db.Name = model.Name ?? ""; db.Description = model.Description ?? ""; db.Manufacturer = model.Manufacturer ?? ""; db.RatedPower = model.RatedPower; db.RotorDiameter = model.RotorDiameter; db.RotorOrientation = model.RotorOrientation ?? ""; db.RotorConfiguration = model.RotorConfiguration ?? ""; db.Control = model.Control ?? ""; db.HubHeight = model.HubHeight; db.HubDiameter = model.HubDiameter; db.WindSpeedCutIn = model.WindSpeedCutIn; db.WindSpeedRated = model.WindSpeedRated; db.WindSpeedCutOut = model.WindSpeedCutOut; db.RotorSpeedCutIn = model.RotorSpeedCutIn; db.RotorSpeedRated = model.RotorSpeedRated; db.TipSpeedRated = model.TipSpeedRated; db.RotorMass = model.RotorMass; db.NacelleMass = model.NacelleMass; db.TowerMass = model.TowerMass; _ctx.SaveChanges(); }
/// <summary> /// Deprecated Method for adding a new object to the DTurbines EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToDTurbines(DTurbine dTurbine) { base.AddObject("DTurbines", dTurbine); }
/// <summary> /// Create a new DTurbine object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="created">Initial value of the Created property.</param> /// <param name="updated">Initial value of the Updated property.</param> /// <param name="isPublic">Initial value of the IsPublic property.</param> /// <param name="name">Initial value of the Name property.</param> /// <param name="description">Initial value of the Description property.</param> public static DTurbine CreateDTurbine(global::System.Guid id, global::System.DateTime created, global::System.DateTime updated, global::System.Boolean isPublic, global::System.String name, global::System.String description) { DTurbine dTurbine = new DTurbine(); dTurbine.Id = id; dTurbine.Created = created; dTurbine.Updated = updated; dTurbine.IsPublic = isPublic; dTurbine.Name = name; dTurbine.Description = description; return dTurbine; }
public static void MapFromDb(VTurbine model, DTurbine db, IPrincipal user) { model.Id = db.Id; model.Author = db.Author ?? ""; model.Name = db.Name ?? ""; model.Description = db.Description ?? ""; model.Manufacturer = db.Manufacturer ?? ""; model.RatedPower = db.RatedPower ?? 0; model.RotorDiameter = db.RotorDiameter ?? 0; model.RotorOrientation = db.RotorOrientation ?? ""; model.RotorConfiguration = db.RotorConfiguration ?? ""; model.Control = db.Control ?? ""; model.HubHeight = db.HubHeight ?? 0; model.HubDiameter = db.HubDiameter ?? 0; model.WindSpeedCutIn = db.WindSpeedCutIn ?? 0; model.WindSpeedRated = db.WindSpeedRated ?? 0; model.WindSpeedCutOut = db.WindSpeedCutOut ?? 0; model.RotorSpeedCutIn = db.RotorSpeedCutIn ?? 0; model.RotorSpeedRated = db.RotorSpeedRated ?? 0; model.TipSpeedRated = db.TipSpeedRated ?? 0; model.RotorMass = db.RotorMass ?? 0; model.NacelleMass = db.NacelleMass ?? 0; model.TowerMass = db.TowerMass ?? 0; model.IsPublic = db.IsPublic; model.CanEdit = db.Author == user.Identity.Name; }
public static VTurbine MapFromDb(DTurbine db, IPrincipal user) { var model = new VTurbine(); MapFromDb(model, db, user); return model; }