public static void AddDocSpec(documentSpecialization docSpec) { var entity = new sovadb001Entities0(); entity.documentSpecializations.Add(docSpec); entity.SaveChanges(); }
public ActionResult Save(RegisterApplicationForm doc) { var entity = new sovadb001Entities0(); order norder = new order(); //entity.orders.Add(norder); int[] specComplexity = new int[doc.spec.Length + 1]; int i = 1; specComplexity[0] = (int)DataBase.GetSpecialization(doc.Language).complexity; documentSpecialization dc = new documentSpecialization(); dc.IdSpecialization = DataBase.GetSpecialization(doc.Language).IdSpecialization; entity.documentSpecializations.Add(dc); foreach (var spec in doc.spec) { specComplexity[i] = (int)DataBase.GetSpecialization(spec).complexity; i++; documentSpecialization ndocSpec = new documentSpecialization(); //ndocSpec.order = norder; ndocSpec.IdOrder = norder.IdOrder; // ndocSpec.specialization = DataBase.GetSpecialization(spec); ndocSpec.IdSpecialization = DataBase.GetSpecialization(spec).IdSpecialization; //DataBase.AddDocSpec(ndocSpec); entity.documentSpecializations.Add(ndocSpec); // norder.documentSpecializations.Add(ndocSpec); } norder.dateOfCompletion = DateTime.Now; norder.name = doc.name; norder.description = doc.description; norder.deadline = doc.deadline; user iduser = auth.AuthHelper.GetUser(HttpContext); if (iduser.roleid == 1 && doc.userId != 0) { norder.idUser = doc.userId; } else { norder.idUser = auth.AuthHelper.GetUser(HttpContext).Id; } norder.isDone = false; norder.inProgress = false; //DataBase.AddApplication(norder); entity.orders.Add(norder); entity.SaveChanges(); return(RedirectToAction("Index", "Home")); // } }