コード例 #1
0
        public ActionResult Teachers_Destroy([DataSourceRequest] DataSourceRequest request,
                                             global::StudentInternshipManagement.Models.Entities.Teacher teacher)
        {
            if (ModelState.IsValid)
            {
                _teacherService.Delete(teacher);
            }

            return(Json(new[] { teacher }.ToDataSourceResult(request, ModelState)));
        }
コード例 #2
0
        public ActionResult Edit(HttpPostedFileBase file, global::StudentInternshipManagement.Models.Entities.Teacher model)
        {
            if (ModelState.IsValid)
            {
                if (file != null)
                {
                    var extension    = Path.GetExtension(file.FileName);
                    var physicalPath = Path.Combine(Server.MapPath("~/Images/avatars/"),
                                                    $"{model.User.UserName}{extension}");
                    file.SaveAs(physicalPath);
                    model.User.Avatar = $"{model.User.UserName}{extension}";
                }

                ViewBag.Message = _teacherService.Update(model) ? "Thành công" : "Thất bại";
            }

            return(RedirectToAction("Index"));
        }