public ActionResult CreateAlcohol(CreateAlcoholVM model, List<String> AssociatedReports) { var db = new ChwinockEntities(); var newAlcohol = new Alcohol(); newAlcohol.AlcoholID = Guid.NewGuid(); newAlcohol.Name = model.Alcohol.Name; newAlcohol.Price = model.Alcohol.Price; newAlcohol.Percentage = model.Alcohol.Percentage; newAlcohol.Type = model.Alcohol.Type; newAlcohol.Thoughts = model.Alcohol.Thoughts; if (AssociatedReports != null) { foreach (var r in AssociatedReports) { var id = Guid.Parse(r); newAlcohol.Reports.Add(db.Reports.Single(x => x.ReportID == id)); } } db.Alcohols.AddObject(newAlcohol); db.SaveChanges(); return RedirectToAction("Manage"); }
/// <summary> /// Create a new Alcohol object. /// </summary> /// <param name="alcoholID">Initial value of the AlcoholID property.</param> /// <param name="name">Initial value of the Name property.</param> public static Alcohol CreateAlcohol(global::System.Guid alcoholID, global::System.String name) { Alcohol alcohol = new Alcohol(); alcohol.AlcoholID = alcoholID; alcohol.Name = name; return alcohol; }
/// <summary> /// Deprecated Method for adding a new object to the Alcohols EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToAlcohols(Alcohol alcohol) { base.AddObject("Alcohols", alcohol); }
public CreateAlcoholVM(Alcohol alcohol) { Alcohol = alcohol; Reports = new ChwinockEntities().Reports; }
//Constructors public CreateAlcoholVM() { Alcohol = new Alcohol(); Reports = new ChwinockEntities().Reports; }