public async Task <IActionResult> AddNewFaculty(AddFacultyModel model) { FacultyDTO newItem = new FacultyDTO() { facultyName = model.Name, facultyAddress = model.Address }; await faculty.Create(newItem); return(RedirectToAction("GetFaculty", "EducationalDepartment")); }
public async Task <ActionResult> Create(FacultyViewModel facultyViewModel) { var existingCode = await _facultyService.FindByCode(facultyViewModel.Code); if (existingCode == null) { var faculty = new Faculty { Code = facultyViewModel.Code, Name = facultyViewModel.Name }; await _facultyService.Create(faculty); return(Ok()); } else { return(BadRequest("Ya existe una Facultad con este codigo")); } }
public ActionResult CreateFaculty(CreateFacultyPost createFacultyPost, HttpPostedFileBase image) { if (ModelState.IsValid) { FacultyDTO faculty = new FacultyDTO { Name = createFacultyPost.Name, Description = createFacultyPost.Description, FacultySubjects = createFacultyPost.FacultySubjects }; if (image != null) { string filePath = "/Content/Image/Faculties/" + faculty.Name + Path.GetExtension(image.FileName); image.SaveAs(Server.MapPath(filePath)); faculty.Photo = filePath; } _faculty.Create(faculty); } return(RedirectToAction("Faculties")); }
public ActionResult FacultyCreate(Faculty faculty) { if (!ModelState.IsValid) { return(View(faculty)); } else if (_facultyService.Find(f => f.FacultyNumber == faculty.FacultyNumber).Any()) { ModelState.AddModelError("FacultyCreate", "This faculty already exists."); return(View(faculty)); } else if (faculty.AllPlaces < faculty.BudgetPlaces) { ModelState.AddModelError("FacultyCreate", "Number of budget seats mast be less or equal than all seats number."); return(View(faculty)); } _facultyService.Create(faculty); return(RedirectToAction("GetFaculty", "Faculty", new { area = "Operator" })); }