Example #1
0
        public ActionResult CreateSpecialty(CreateSpecialty createSpecialty, HttpPostedFileBase image)
        {
            if (ModelState.IsValid)
            {
                SpecialtyDTO specialty = new SpecialtyDTO
                {
                    Number       = createSpecialty.Number,
                    Name         = createSpecialty.Name,
                    BudgetPlaces = createSpecialty.BudgetPlaces,
                    TotalPlaces  = createSpecialty.TotalPlaces,
                    Description  = createSpecialty.Description,
                    FacultyId    = createSpecialty.FacultyId
                };
                if (image != null)
                {
                    string filePath = "/Content/Image/Specialties/" + specialty.Name + Path.GetExtension(image.FileName);
                    image.SaveAs(Server.MapPath(filePath));
                    specialty.Photo = filePath;
                }

                _specialty.Create(specialty);
            }

            return(View(new CreateSpecialty {
                FacultyId = createSpecialty.FacultyId
            }));
        }
Example #2
0
        public ActionResult EditSpecialty(EditSpecialty editSpecialty, HttpPostedFileBase image)
        {
            if (ModelState.IsValid)
            {
                SpecialtyDTO specialty = new SpecialtyDTO
                {
                    Id           = editSpecialty.Id,
                    Number       = editSpecialty.Number,
                    Name         = editSpecialty.Name,
                    Description  = editSpecialty.Description,
                    FacultyId    = editSpecialty.FacultyId,
                    BudgetPlaces = editSpecialty.BudgetPlaces,
                    TotalPlaces  = editSpecialty.TotalPlaces
                };
                if (image != null)
                {
                    string filePath = "/Content/Image/Specialties/" + specialty.Name + Path.GetExtension(image.FileName);
                    if (editSpecialty.Photo != null)
                    {
                        System.IO.File.Delete(Server.MapPath(filePath));
                    }
                    image.SaveAs(Server.MapPath(filePath));
                    specialty.Photo = filePath;
                }
                else
                {
                    specialty.Photo = editSpecialty.Photo;
                }

                _specialty.Update(specialty);
            }
            return(RedirectToAction("Specialties", new { facultyId = editSpecialty.FacultyId }));
        }
Example #3
0
        public async Task <IActionResult> PutSpecialty([FromRoute] int id, [FromBody] SpecialtyDTO specialtyDto)
        {
            if (id != specialtyDto.ID)
            {
                return(BadRequest());
            }

            var specialty = await _context.Specialties.Include(s => s.College).FirstOrDefaultAsync(s => s.ID == specialtyDto.ID);

            specialty.CollegeId = specialtyDto.College.ID;
            specialty.Name      = specialtyDto.Name;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SpecialtyExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(Ok());
        }
Example #4
0
        public static Specialty SpecialtyDTOToSpecialty(SpecialtyDTO specialtyDTO)
        {
            Specialty specialty = new Specialty();

            specialty.Id   = specialtyDTO.Id;
            specialty.Name = specialtyDTO.Name;
            return(specialty);
        }
Example #5
0
        public static SpecialtyDTO SpecialtyToSpecialtyDTO(Specialty specialty)
        {
            SpecialtyDTO specialtyDTO = new SpecialtyDTO();

            specialtyDTO.Id   = specialty.Id;
            specialtyDTO.Name = specialty.Name;
            return(specialtyDTO);
        }
        private void AppointmentDoctorSpecializationComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            DoctorService doctorService = new DoctorService();

            SpecialtyDTO     selectedSpecialty            = (SpecialtyDTO)AppointmentDoctorSpecializationComboBox.SelectedItem;
            List <DoctorDTO> doctorsWithSelectedSpecialty = doctorService.GetDoctorsBySpecialty(selectedSpecialty.Id);

            AppointmentDoctorComboBox.ItemsSource = doctorsWithSelectedSpecialty;
        }
Example #7
0
        public async Task <IActionResult> PostSpecialty([FromBody] SpecialtyDTO specialtyDto)
        {
            _context.Specialties.Add(new Specialty()
            {
                CollegeId = specialtyDto.College.ID, Name = specialtyDto.Name
            });
            await _context.SaveChangesAsync();

            return(Ok());
        }
Example #8
0
        public void Create(SpecialtyDTO specialtyDTO)
        {
            Specialty specialty = new Specialty
            {
                Number       = specialtyDTO.Number,
                Name         = specialtyDTO.Name,
                BudgetPlaces = specialtyDTO.BudgetPlaces,
                TotalPlaces  = specialtyDTO.TotalPlaces,
                Photo        = specialtyDTO.Photo,
                FacultyId    = specialtyDTO.FacultyId,
                Description  = specialtyDTO.Description
            };

            _database.SpecialtyRepository.Create(specialty);
            _database.Save();
        }