示例#1
0
        public async Task <ActionResult <speciality> > Postspeciality(speciality speciality)
        {
            _context.specialities.Add(speciality);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("Getspeciality", new { id = speciality.id }, speciality));
        }
示例#2
0
        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());
        }
示例#3
0
        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());
        }
示例#4
0
 public void CreateSpeciality(speciality objSpeciality)
 {
     using (var dataContext = new FinalAppWebEntities())
     {
         dataContext.specialities.Add(objSpeciality);
         dataContext.SaveChanges();
     }
 }
示例#5
0
        public ActionResult DeleteConfirmed(int id)
        {
            speciality speciality = db.specialities.Find(id);

            db.specialities.Remove(speciality);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
示例#6
0
 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));
 }
示例#7
0
        public ActionResult Create([Bind(Include = "id,specialityName")] speciality speciality)
        {
            if (ModelState.IsValid)
            {
                db.specialities.Add(speciality);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(speciality));
        }
示例#8
0
 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);
     }
 }
示例#9
0
        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));
        }
示例#10
0
        // 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));
        }
示例#11
0
 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();
     }
 }
示例#12
0
        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());
        }
示例#13
0
        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"));
            }
        }
示例#14
0
        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);
        }
示例#15
0
        public void CreateSpeciality(speciality objSpeciality)
        {
            ISpecialityRepository repository = new SpecialityRepository();

            repository.CreateSpeciality(objSpeciality);
        }