public void Set(TblJobOrder ob) { if (ob.JobOrderId == 0) { db.TblJobOrder.Add(ob); } else { if (ob.AttachmentType != null) { db.TblJobOrderAttachmentType.RemoveRange(db.TblJobOrderAttachmentType.Where(o => o.JobOrderId == ob.JobOrderId)); db.TblJobOrderAttachmentType.AddRange(ob.AttachmentType); } if (ob.ProjectType != null) { db.TblJobOrderProjectType.RemoveRange(db.TblJobOrderProjectType.Where(o => o.JobOrderId == ob.JobOrderId)); db.TblJobOrderProjectType.AddRange(ob.ProjectType); } if (ob.EquipmentType != null) { db.TblJobOrderEquipmentType.RemoveRange(db.TblJobOrderEquipmentType.Where(o => o.JobOrderId == ob.JobOrderId)); db.TblJobOrderEquipmentType.AddRange(ob.EquipmentType); } if (ob.LandType != null) { db.TblJobOrderLandType.RemoveRange(db.TblJobOrderLandType.Where(o => o.JobOrderId == ob.JobOrderId)); db.TblJobOrderLandType.AddRange(ob.LandType); } if (ob.ObstructionType != null) { db.TblJobOrderObstructionType.RemoveRange(db.TblJobOrderObstructionType.Where(o => o.JobOrderId == ob.JobOrderId)); db.TblJobOrderObstructionType.AddRange(ob.ObstructionType); } if (ob.UndergroundType != null) { db.TblJobOrderUndergroundType.RemoveRange(db.TblJobOrderUndergroundType.Where(o => o.JobOrderId == ob.JobOrderId)); db.TblJobOrderUndergroundType.AddRange(ob.UndergroundType); } if (ob.SurveyDetail != null) { db.TblJobOrderSurveyDetail.RemoveRange(db.TblJobOrderSurveyDetail.Where(o => o.JobOrderId == ob.JobOrderId)); db.TblJobOrderSurveyDetail.AddRange(ob.SurveyDetail); } db.SaveChanges(); db.TblJobOrder.Update(ob); // db.Entry(ob).State = EntityState.Modified; } }
public HttpResponseMessage SignUp(User user) { ReturnedResult result = new ReturnedResult(); var checkUser = db.Users.Where(x => x.UserName == user.UserName).FirstOrDefault(); if (checkUser != null) { result.ErrorString = "sistemde böyle bir kullanıcı mevcut. lüften kullanıcı adını değişitirip tekrar deneyiniz."; result.Success = false; } else { if (ModelState.IsValid) { db.Users.Add(user); db.SaveChanges(); result.ErrorString = "başarıyla kayıt olundu. aşağıdan giriş yapabilirsiniz."; result.Success = true; } } return(Request.CreateResponse(HttpStatusCode.OK, result)); }
public string Post(Person ob) { db.Person.Add(ob); db.SaveChanges(); return("Post data Id:" + ob.Id); }
public IActionResult Index() { List <int> primes = sieve(); ViewBag.primes = primes; dotnet.Models.ViewModels.IndexViewModel model = new dotnet.Models.ViewModels.IndexViewModel(); //20 random values and min + max model.values = twentyRandom(); int max = 0; int min = 10000000; foreach (int r in model.values) { if (r > max) { max = r; } if (r < min) { min = r; } } model.Max = max; model.Min = min; //hash of values from database var fiftyValues = _context.Fiftyvalues.ToList(); model.fifty = new List <FiftyValuesView>(); foreach (Fiftyvalues v in fiftyValues) { FiftyValuesView fv = new FiftyValuesView(); fv.Value = v.Value; fv.Id = v.Id; fv.Hash = ComputeSha256Hash(v.Value); model.fifty.Add(fv); } //names var names = _context.Names.ToList(); var sorted_names = MergeSort(names); model.names = new List <Names>(); model.names = sorted_names; //make sigma for display on page Sigma s = new Sigma(); s.nodes = new List <Nodes>(); s.edges = new List <Edges>(); int i = 1; foreach (Names n in names) { s.nodes.Add(new Nodes(n.Id.ToString())); string[] friends = n.Friends.Split(","); foreach (string f in friends) { s.edges.Add(new Edges(i, n.Id.ToString(), f)); i++; } } model.s = s; //bfs for shortest path var graph = new Graph <int>(s.ToVertices(), s.ToTuples()); var algorithms = new Algorithms(); var startVertex = 6; var shortestPath = algorithms.ShortestPathFunction(graph, startVertex); model.path = string.Join(" => ", shortestPath(77)); //string pairs var hash = "acb80281e4e94213c7452a81fa08f61893eff5ffa62d50876da8d1fed4710d95"; var strings = new List <Tuple <string, string> >(); strings.Add(Tuple.Create("ethereal", "front")); strings.Add(Tuple.Create("ask", "release")); strings.Add(Tuple.Create("bucket", "unique")); strings.Add(Tuple.Create("plug", "average")); strings.Add(Tuple.Create("trade", "weather")); strings.Add(Tuple.Create("card", "wide")); strings.Add(Tuple.Create("numberless", "copper")); strings.Add(Tuple.Create("fruit", "example")); strings.Add(Tuple.Create("slap", "pause")); strings.Add(Tuple.Create("jittery", "confused")); model.hashPresent = checkForHash(hash, strings); //insert statement Transactions tx = new Transactions(); tx.Customer = "Ben Hogan"; tx.Price = 900; tx.Item = "Cleek"; _context.Transactions.Add(tx); _context.SaveChanges(); return(View(model)); }