public async Task <IActionResult> CreatePost(Teacher teacher, List <Class> classes) { teacher.classes = classes; if (ModelState.IsValid) { await teacherService.Add(teacher); } return(RedirectToAction("Index")); }
public IActionResult Add(Teacher teacher) { var result = _teacherService.Add(teacher); if (result.Success) { return(Ok(result)); } return(BadRequest(result)); }
public ActionResult Teachers_Create([DataSourceRequest] DataSourceRequest request, global::StudentInternshipManagement.Models.Entities.Teacher teacher) { if (ModelState.IsValid) { _teacherService.Add(teacher); } return(Json(new[] { teacher }.ToDataSourceResult(request, ModelState))); }
public ActionResult Create(Teacher model) { if (ModelState.IsValid) { teacherService.Add(model); return(RedirectToAction("Index")); } else { return(View()); } }
public void AddStudent(Student student, Teacher teacher) { try { studentService.Add(student); teacherService.Add(teacher); commonUnitofWork.SaveChanges(); } catch (Exception) { throw; } }
public IHttpActionResult AddTeacher([FromBody] TeacherDto dto) { if (dto == null) { return(BadRequest("null input")); } var result = _teacherService.Add(dto); if (result == true) { return(Ok()); } return(BadRequest("invalid input")); }
public IActionResult Add([FromQuery] TeacherViewModel model) { var TeacherResponse = _TeacherService.Add(new Teacher { Name = model.Name, SurName = model.SurName, Email = model.Email, LessonId = model.LessonId }); if (TeacherResponse.IsSucceeded && TeacherResponse.Result != null) { return(Ok(TeacherResponse.Result)); } return(TeacherResponse.HttpGetResponse()); }
public IActionResult Add(Teacher teacher) { if (!Auth.IsAdmin(Request)) { return(BadRequest(new ErrorResult(Messages.AccessDenied))); } var result = _teacherService.Add(teacher); if (result.Success) { return(Ok(result)); } else { return(BadRequest(result)); } }
public IActionResult TeacherAdd([FromBody] Teacher teacher) { teacher.ID = Guid.NewGuid(); teacher.CreateTime = DateTime.Now; teacher.CreateBy = (Guid)teacher.LastUpdateBy; teacher.LastUpdateTime = DateTime.Now; teacher.IsDelete = false; try { _teacher.Add(teacher); } catch (Exception e) { return(new JsonResult(new { code = ResultCode.错误, message = e.Message })); } return(new JsonResult(new { code = ResultCode.正常 })); }
public ActionResult Index() { // db.Database.Create(); //var list = db.Set<Student>().ToList(); //db.Database.Initialize(true); //var model = new Student { Name = "撒旦", Age = 12, Sex = "男", Point = 11, TeacherId = 1 }; //db.Stduents.Add(model); //db.SaveChanges(); var model = new Teacher { Age = 11, Name = "速度速度", Salary = 34343, Sex = "女", Dog = "sds" }; teaSer.Add(model); ViewBag.Message = "Database is build success!"; return(View()); }
public JsonResult TeacherEdit(int TeacherId, TeacherModel TeacherModel) { try { if (TeacherId == 0) { Core3Base.Infra.Data.Entity.Teacher Teacher = new Core3Base.Infra.Data.Entity.Teacher { Name = TeacherModel.Teacher.Name, Email = TeacherModel.Teacher.Email, IsActive = TeacherModel.Teacher.IsActive, SurName = TeacherModel.Teacher.SurName, LessonId = TeacherModel.Teacher.LessonId }; return(Json(_teacherService.Add(Teacher).HttpGetResponse())); } else { var Teacher = _teacherService.GetTeacherById(TeacherId).Result; Teacher.Name = TeacherModel.Teacher.Name; Teacher.Email = TeacherModel.Teacher.Email; Teacher.IsActive = TeacherModel.Teacher.IsActive; Teacher.SurName = TeacherModel.Teacher.SurName; Teacher.LessonId = TeacherModel.Teacher.LessonId; Teacher.DateModified = DateTime.Now; return(Json(_teacherService.Update(Teacher).HttpGetResponse())); } } catch (Exception e) { return(Json(e.Message)); } }
public async Task <IHttpActionResult> Add([FromBody] TeacherDTO teacher) { var response = new OverviewResponse <TeacherOverview>(); try { Teacher newTeacher = _mapper.Map <TeacherDTO, Teacher>(teacher); var result = _teacherService.Add(newTeacher); if (result == null) { response.IsSuccess = false; response.Errors.Add("Already exists!"); return(Ok(response)); } var overviews = GetTeacherOverview(); response.IsSuccess = !response.Errors.Any(); response.Overview = overviews; } catch (Exception ex) { response.IsSuccess = false; response.Errors.Add(ex.Message); response.Errors.Add("-----------------------------------"); response.Errors.Add(ex.InnerException.Message); var overviews = GetTeacherOverview(); response.Overview = overviews; return(Ok(response)); } //Call overview var hubContext = GlobalHost.ConnectionManager.GetHubContext <ClientHub>(); hubContext.Clients.All.reloadTeacher(response); return(Ok(response)); }
public async Task <bool> Add(Teacher data) { return(await service.Add(data)); }
public int Add([FromBody] Teacher teacher) { return(_service.Add(teacher).Id); }
public ActionResult Create(ogretmenler ogretmenler) { teacherService.Add(ogretmenler); return(View("List")); }
public async Task <ActionResult <TeacherDto> > Add(TeacherInputDto input) { var dto = await _service.Add(input); return(CreatedAtAction(nameof(Get), new { id = dto.TeacherId }, dto)); }
public void Post([FromBody] Teacher teacher) { _teacherService.Add(teacher); }
public void Add_AddTeachers_Verify_MethodCalled() { //Arrange List <Lesson> lessons = new List <Lesson>() { new Lesson { WeekNumber = Week.FirstWeek, DayOfTheWeek = Day.Thursday, LessonNumber = 1, LessonName = "Programming", Group = null, Teacher = null }, new Lesson { WeekNumber = Week.SecondWeek, DayOfTheWeek = Day.Monday, LessonNumber = 3, LessonName = "Math", Group = null, Teacher = null }, new Lesson { WeekNumber = Week.FirstWeek, DayOfTheWeek = Day.Tuesday, LessonNumber = 3, LessonName = "Philosophy", Group = null, Teacher = null } }; Teacher[] teachers = { new Teacher { Name = "Roman", Surname = "Kutsenko", Post = "Teacher", Lessons = lessons }, new Teacher { Name = "Zinaida", Surname = "Kuchma", Post = "Teacher", Lessons = lessons }, new Teacher { Name = "Vasil", Surname = "Bondarchuk", Post = "Teacher", Lessons = lessons } }; Mock <ITeacherService> service = new Mock <ITeacherService>(); service.Setup(mock => mock.Add(teachers[0])).Verifiable(); service.Setup(mock => mock.Add(teachers[1])).Verifiable(); service.Setup(mock => mock.Add(teachers[2])).Verifiable(); //Act ITeacherService Service = service.Object; Service.Add(teachers[0]); Service.Add(teachers[1]); Service.Add(teachers[2]); //Assert service.VerifyAll(); }