Beispiel #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
            }));
        }
Beispiel #2
0
        public IActionResult CreateSpecialty([FromBody] SpecialtyRequest request)
        {
            if (request == null)
            {
                return(NotFound());
            }

            var specialty = _mapper.Map <Speciality>(request);
            var result    = _specialtyService.Create(specialty);

            if (result == null)
            {
                return(NotFound());
            }

            return(Ok(specialty));
        }