public IHttpActionResult PutHaplotypeFrequency(int id, HaplotypeFrequency haplotypeFrequency) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != haplotypeFrequency.Id) { return(BadRequest()); } db.Entry(haplotypeFrequency).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!HaplotypeFrequencyExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetHaplotypeFrequency(int id) { HaplotypeFrequency haplotypeFrequency = db.HaplotypeFrequencies.Find(id); if (haplotypeFrequency == null) { return(NotFound()); } return(Ok(haplotypeFrequency)); }
public IHttpActionResult PostHaplotypeFrequency(HaplotypeFrequency haplotypeFrequency) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.HaplotypeFrequencies.Add(haplotypeFrequency); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = haplotypeFrequency.Id }, haplotypeFrequency)); }
public IHttpActionResult DeleteHaplotypeFrequency(int id) { HaplotypeFrequency haplotypeFrequency = db.HaplotypeFrequencies.Find(id); if (haplotypeFrequency == null) { return(NotFound()); } db.HaplotypeFrequencies.Remove(haplotypeFrequency); db.SaveChanges(); return(Ok(haplotypeFrequency)); }
public IHttpActionResult GetHaplotypeFrequencies(string PopulationName, string Haplotype, string UserName, string Id, string isDeleted, string Count, string Frequency, string LinkDisEq) { try { var userdet = new User(); userdet = db.Users.Where(u => u.UserName == UserName).FirstOrDefault(); var id = 0; int HapId = int.Parse(Id); decimal Hapcount = decimal.Parse(Count); decimal HapFreq = decimal.Parse(Frequency); decimal HapLinkDisEq = decimal.Parse(Count); bool Hapstatus = bool.Parse(isDeleted); var selpop = db.Populations.Where(p => p.Name == PopulationName).FirstOrDefault(); if (HapId == 0) { var newhap = new HaplotypeFrequency { PopulationId = selpop.Id, Haplotype = Haplotype, Count = Hapcount, Frequency = HapFreq, LinkageDisEquilibrium = HapLinkDisEq, CreatedBy = userdet.Id, LastModifiedBy = userdet.Id, CreatedDateTime = DateTimeOffset.Now, LastModifiedDateTime = DateTimeOffset.Now, isDeleted = false, }; db.HaplotypeFrequencies.Add(newhap); db.SaveChanges(); id = newhap.Id; } else { id = HapId; var upd = db.HaplotypeFrequencies.Where(p => p.Id == id).FirstOrDefault(); upd.PopulationId = selpop.Id; upd.Count = Hapcount; upd.Frequency = HapFreq; upd.LinkageDisEquilibrium = HapLinkDisEq; upd.Haplotype = Haplotype; upd.LastModifiedBy = userdet.Id; upd.LastModifiedDateTime = DateTimeOffset.Now; upd.isDeleted = Hapstatus; db.SaveChanges(); } var res = db.HaplotypeFrequencies.Where(h => h.Id == id).Select(f => new { f.Id, f.Haplotype, f.Count, f.Frequency, f.LinkageDisEquilibrium, populationName = db.Populations.Where(p => p.Id == f.PopulationId).FirstOrDefault().Name, f.CreatedDateTime, f.LastModifiedDateTime, f.isDeleted, createdbyuser = db.Users.Where(u => u.Id == f.CreatedBy).FirstOrDefault().UserName, LastModifiedByUser = db.Users.Where(u => u.Id == f.LastModifiedBy).FirstOrDefault().UserName }).ToList(); return(Json(res)); } catch (Exception ex) { return(Json(ex)); } }