Ejemplo n.º 1
0
        public IHttpActionResult Post(Teacher teacher)
        {
            TeacherService service = new TeacherService();
            var            add     = service.Add(teacher);

            return(this.Ok(add));
        }
Ejemplo n.º 2
0
        public IHttpActionResult AddTeacher(TeacherModel model)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

                var service = new TeacherService();

                int id = service.Add(BindingManager.ToTeacherEntity(model));
                if (id == 0)
                {
                    return(Ok(new ResponseModel()
                    {
                        Result = ResponseType.Error, Description = "Entity was not created."
                    }));
                }

                return(Ok(new ResponseModel()
                {
                    Result = ResponseType.Success
                }));
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);

                return(InternalServerError(ex));
            }
        }
Ejemplo n.º 3
0
        public ActionResult Add(TeacherEditViewModel Teacher)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }

            TeacherService.Add(Teacher);
            return(RedirectToAction("Teacher"));
        }
Ejemplo n.º 4
0
        // POST: api/teacher
        public HttpResponseMessage Post([FromBody] Teacher value)
        {
            HttpResponseMessage msg = new HttpResponseMessage(HttpStatusCode.Conflict);

            using (ITeacherService ts = new TeacherService(WebApiApplication.connection))
            {
                ts.Add(Mapper.Map <BLL.Objects.Teacher>(value));
                msg.StatusCode = HttpStatusCode.OK;
            }
            return(msg);
        }
Ejemplo n.º 5
0
 public ActionResult Create(Teacher teacher)
 {
     try
     {
         teacherService.Add(teacher);
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
Ejemplo n.º 6
0
        public void testAddStandaloneTeacher()
        {
            Assert.Null(serv.GetByUserName(USERNAME));
            // Arrange
            int count = serv.All().Count();


            // Act
            var result = this.userManager.Create(teacherUser, "testpassword");

            if (result.Succeeded)
            {
                this.userManager.AddToRole(teacherUser.Id, GlobalConstants.TeacherRoleName);
            }
            MichtavaResult res = serv.Add(entity);

            // Assert
            Assert.AreEqual(count + 1, serv.All().Count());
            Assert.NotNull(serv.GetByUserName(USERNAME));
            Assert.True(res is MichtavaSuccess);
            Assert.True(serv.HardDelete(entity) is MichtavaSuccess);
            this.userManager.Delete(teacherUser);
            Assert.Null(serv.GetByUserName(USERNAME));
        }
Ejemplo n.º 7
0
        public IActionResult AddTeacher([FromBody] Teacher teacher)
        {
            teacher.Id         = Guid.NewGuid().ToString();
            teacher.Created    = DateTime.Now;
            teacher.CreatedBy  = "admin";
            teacher.Modified   = DateTime.Now;
            teacher.ModifiedBy = "admin";
            teacher.IsActive   = true;

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            bool addTeacher = service.Add(teacher);

            if (addTeacher)
            {
                return(Ok(teacher.Name));
            }

            return(BadRequest("Please try again"));
        }
Ejemplo n.º 8
0
        public IActionResult AddCourse([FromBody] Teacher teacher)
        {
            teacher.Id         = Guid.NewGuid().ToString();
            teacher.Created    = DateTime.Now;
            teacher.Modified   = DateTime.Now;
            teacher.CreatedBy  = "system";
            teacher.ModifiedBy = "system";
            teacher.IsActive   = true;

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            bool added = _service.Add(teacher);

            if (added)
            {
                return(Ok(teacher.Id));
            }

            return(BadRequest("Couldn't save course."));
        }