public ActionResult DeleteTeacher(string name)
        {
            var teacher = _teachersService.GetByName(name);

            _teachersService.Delete(teacher.Id);
            return(Redirect("/Teachers/All"));
        }
Esempio n. 2
0
        public HttpResponseMessage DeleteTeacher(string id)
        {
            string userId = ((ClaimsPrincipal)RequestContext.Principal).FindFirst(x => x.Type == "UserId").Value;

            logger.Info("UserId: " + userId + ": Requesting Teacher Remove for Teacher Id: " + id);

            try
            {
                Teacher user = teachersService.Delete(id);

                if (user == null)
                {
                    logger.Info("The Teacher with id: " + id + " was not found.");
                    return(Request.CreateResponse(HttpStatusCode.BadRequest, "The Teacher with id: " + id + " was not found."));
                }

                logger.Info("Success!");
                return(Request.CreateResponse(HttpStatusCode.OK));
            }
            catch (Exception e)
            {
                logger.Error(e);
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, e));
            }
        }
Esempio n. 3
0
        public ActionResult Delete(int id)
        {
            var filePath = Server.MapPath("~/Content/img/" + teachersService.GetTeachers(id).ImageLink);

            if (System.IO.File.Exists(filePath))
            {
                System.IO.File.Delete(filePath);
            }
            teachersService.Delete(id);
            return(RedirectToAction("Index"));
        }
Esempio n. 4
0
        public IHttpActionResult Delete(Guid id)
        {
            var result = _teachersService.Delete(id);

            return(ResultToHttpActionResult(result));
        }