public async Task <ActionResult <speciality> > Postspeciality(speciality speciality) { _context.specialities.Add(speciality); await _context.SaveChangesAsync(); return(CreatedAtAction("Getspeciality", new { id = speciality.id }, speciality)); }
public async Task <IActionResult> Putspeciality(int id, speciality speciality) { if (id != speciality.id) { return(BadRequest()); } _context.Entry(speciality).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!specialityExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> Disable(int id) { speciality b = _context.specialities.FirstOrDefault(u => u.id == id && u.status == true); if (b != null) { b.status = false; } else { b = null; } try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!specialityExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public void CreateSpeciality(speciality objSpeciality) { using (var dataContext = new FinalAppWebEntities()) { dataContext.specialities.Add(objSpeciality); dataContext.SaveChanges(); } }
public ActionResult DeleteConfirmed(int id) { speciality speciality = db.specialities.Find(id); db.specialities.Remove(speciality); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "id,specialityName")] speciality speciality) { if (ModelState.IsValid) { db.Entry(speciality).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(speciality)); }
public ActionResult Create([Bind(Include = "id,specialityName")] speciality speciality) { if (ModelState.IsValid) { db.specialities.Add(speciality); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(speciality)); }
public speciality GetSpecialityByDescription(string description) { using (var dataContext = new FinalAppWebEntities()) { //LINQ //return dataContext.Customers.ToList(); var custs = from c in dataContext.specialities where c.description == description select c; speciality objSpeciality = custs.FirstOrDefault(); return(objSpeciality); } }
public IHttpActionResult Create(SpecialitiesDto specialitiesDto) { speciality speciality = new speciality { name = specialitiesDto.name, createdon = DateTime.Now, updatedon = DateTime.Now }; ecaseEntity.specialities.Add(speciality); ecaseEntity.SaveChanges(); return(Ok(speciality)); }
// GET: speciality/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } speciality speciality = db.specialities.Find(id); if (speciality == null) { return(HttpNotFound()); } return(View(speciality)); }
public void DeleteSpeciality(int specialityId) { using (var dataContext = new FinalAppWebEntities()) { //Load customer object var cust = from c in dataContext.specialities where c.ID == specialityId select c; speciality objCustomer = cust.FirstOrDefault(); //Remove dataContext.specialities.Remove(objCustomer); //Save dataContext.SaveChanges(); } }
public static IEnumerable <doctor> allDoctors(this speciality speciality) { if (speciality.subSpecialites.Count == 0) { return(speciality.doctors); } var subPecialities = speciality.subSpecialites; List <doctor> doctors = new List <doctor>(); foreach (var sp in subPecialities) { doctors.AddRange(sp.doctors); } doctors.AddRange(speciality.doctors); return(doctors.Distinct()); }
public ActionResult EditSpeciality(string id) // sửa thông tin ngành(lấy thông tin cũ) { if (!user.IsAdmin()) { return(View("Error")); } int id_speciality = Convert.ToInt32(id); try { speciality speciality = Model.GetSpeciality(id_speciality); Model.UpdateLastSeen("Sửa Ngành " + speciality.speciality_name, Url.Action("EditSpeciality/" + id)); return(View(speciality)); } catch (Exception) { return(View("Error")); } }
private void btnAdd_Click(object sender, EventArgs e) { ISpecialityService specialityService = new SpecialityService(); String description = txtSpeciality.Text.ToString().Trim(); speciality objSpeciality = new speciality(); objSpeciality.description = description; if (description.Length == 0) { MessageBox.Show("Type an speciality"); } else if (specialityService.GetSpecialityByDescription(description) != null) { MessageBox.Show("This speciality is already saved. Try another"); } else { specialityService.CreateSpeciality(objSpeciality); MessageBox.Show("Speciality saved"); } this.specialityTableAdapter.Fill(this.finalAppWebDataSet.speciality); }
public void CreateSpeciality(speciality objSpeciality) { ISpecialityRepository repository = new SpecialityRepository(); repository.CreateSpeciality(objSpeciality); }