public static void AddUser(user us) { var entity = new sovadb001Entities0(); entity.users.Add(us); entity.SaveChanges(); }
public static void OrderIsDone(int idOrder) { var entity = new sovadb001Entities0(); entity.orders.First(t => t.IdOrder == idOrder).isDone = true; entity.SaveChanges(); }
public static void AddDoc(document doc) { var entity = new sovadb001Entities0(); entity.documents.Add(doc); entity.SaveChanges(); }
public static void AddDocSpec(documentSpecialization docSpec) { var entity = new sovadb001Entities0(); entity.documentSpecializations.Add(docSpec); entity.SaveChanges(); }
public static void AddApplication(order Order) { var entity = new sovadb001Entities0(); entity.orders.Add(Order); entity.SaveChanges(); }
public static void AddTranslator(int[] idSpec, int idUser) { var entity = new sovadb001Entities0(); translator nt = new translator(); nt.countOfComplitedOrders = 0; nt.IdUser = idUser; entity.translators.Add(nt); entity.SaveChanges(); double[] p = new double[idSpec.Length]; int x = 0; foreach (int i in idSpec) { price pr = GetSpecialization(i).prices.First(t => t.IdTranslator == entity.translators.First(q => q.IdUser == idUser).IdTranslator); specialization s = GetSpecialization(i); if (pr != null) { p[x] = (double)(pr.price1 / s.complexity); } else { p[x] = 0; } x++; } double sum = 0; for (int i = 0; i < p.Length; i++) { sum += p[i]; } sum /= p.Length; double sum1 = 0; for (int i = 0; i < p.Length; i++) { if (p[i] != 0) { p[i] -= sum; p[i] = Math.Abs(p[i]); sum1 += p[i]; } } entity.translators.First(q => q.IdUser == idUser).reputation = (int)sum1; 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")); // } }
public static void AddPrice(int idSpec, int IdUser, double pricespec) { var entity = new sovadb001Entities0(); price np = new price(); np.IdSpecialization = idSpec; np.IdTranslator = entity.translators.First(t => t.IdUser == IdUser).IdTranslator; np.price1 = pricespec; entity.prices.Add(np); entity.SaveChanges(); }
public static int AddSpecialization(string name, bool isL, int complexity) { var entity = new sovadb001Entities0(); specialization spec = new specialization(); spec.name = name; spec.isLanguage = isL; spec.complexity = complexity; entity.specializations.Add(spec); entity.SaveChanges(); return(entity.specializations.First(t => t.name == name).IdSpecialization); }
public static bool UpdateUser(user userUpdate) { var entity = new sovadb001Entities0(); user us = entity.users.First(t => t.Id == userUpdate.Id); if (us != null) { us.name = userUpdate.name; us.email = userUpdate.email; entity.SaveChanges(); return(true); } return(false); }
public static void AddQueue(int idOrder, int idTranslator) { var entity = new sovadb001Entities0(); queue nqueue = new queue(); nqueue.IdTranslator = idTranslator; nqueue.IdOrder = idOrder; nqueue.cost = DataBase.GetCost(idOrder, GetTranslator(idTranslator)); entity.queues.Add(nqueue); entity.orders.First(t => t.IdOrder == idOrder).inProgress = true; entity.orders.First(t => t.IdOrder == idOrder).totalCost = DataBase.GetCost(idOrder, GetTranslator(idTranslator)); entity.SaveChanges(); }
public static void DeleteApplication(int id) { var entity = new sovadb001Entities0(); //auth.AuthHelper.GetUser(HttpContext); foreach (var t in entity.documentSpecializations.Where(r => r.IdOrder == id)) { entity.documentSpecializations.Remove(t); } foreach (var t in entity.documents.Where(r => r.idOrder == id)) { System.IO.File.Delete("C:\\Users\\Олександр\\Documents\\Visual Studio 2012\\Projects\\SovaTranslate_001\\SovaTranslate_001\\Content\\file\\" + t.pathToDoc); entity.documents.Remove(t); } entity.orders.Remove(entity.orders.First(r => r.IdOrder == id)); entity.SaveChanges(); }
public ActionResult AddTranslation(int idOrder, HttpPostedFileBase[] UploadedFiles) { sovadb001Entities0 db = new sovadb001Entities0(); // order o = db.orders.First(t => t.IdOrder == idOrder); foreach (var UpF in UploadedFiles) { string fileName = System.IO.Path.GetFileName(UpF.FileName); UpF.SaveAs(Server.MapPath("~/Content/translate/") + fileName); document ndoc = new document(); ndoc.pathToDoc = fileName; ndoc.isTranslate = true; ndoc.idOrder = idOrder; db.documents.Add(ndoc); } db.orders.First(t => t.IdOrder == idOrder).isDone = true; db.SaveChanges(); return(RedirectToAction("Index", "Home")); }
public static bool UpdateUser(user userUpdate, HttpContextBase httpContext) { var authCookie = httpContext.Request.Cookies["__AUTH"]; var entity = new sovadb001Entities0(); if (authCookie != null) { user user = entity.users.FirstOrDefault(u => u.cookies == authCookie.Value); user.name = userUpdate.name; user.email = userUpdate.email; entity.SaveChanges(); return(true); } else { return(false); } }
public ActionResult Registration(registration u) { if (ModelState.IsValid) { user us = new user(); us.email = u.email.ToString().Trim(); us.name = u.name.ToString().Trim(); us.password = auth.SecurityHelper.Hash(u.password); us.cookies = Guid.NewGuid().ToString(); db.users.Add(us); db.SaveChanges(); return(RedirectToAction("Login")); } //ViewBag.Title = (ex.ToString()); return(View(u)); }