public async Task <ActionResult> _Create(CreateCourseGroupModel model) { var nameResponse = await WepApiMethod.SendApiAsync <bool>(HttpVerbs.Get, $"eLearning/CourseGroup/IsCodeExist?code={model.EnrollmentCode}"); if (!nameResponse.isSuccess) { TempData["ErrorMessage"] = "Group Code Not Valid"; return(RedirectToAction("List")); } if (ModelState.IsValid) { DateTime _now = DateTime.Now; var currentUserId = CurrentUser.UserId.Value; var response = await WepApiMethod.SendApiAsync <int>(HttpVerbs.Post, $"eLearning/CourseGroup", model); if (response.isSuccess) { TempData["SuccessMessage"] = Language.eLearning.CourseGroup.AlertSuccessCreate; //LogActivity(Modules.Learning, "Create Discussion Topic", model); } else { TempData["ErrorMessage"] = Language.eLearning.CourseGroup.AlertFailCreate; } } return(RedirectToAction("List")); }
public async Task <ActionResult> _Create() { var model = new CreateCourseGroupModel(); var _eCode = await WepApiMethod.SendApiAsync <string>(HttpVerbs.Get, $"eLearning/CourseGroup/GetCode"); if (_eCode.isSuccess) { model.EnrollmentCode = _eCode.Data; model.CreatedBy = CurrentUser.UserId.Value; model.UpdatedBy = CurrentUser.UserId.Value; return(View(model)); } else { TempData["ErrorMessage"] = Language.eLearning.CourseGroup.AlertFailGroupCode; return(RedirectToAction("List")); } }
public IHttpActionResult Post([FromBody] CreateCourseGroupModel model) { using (DbEntities _db = new DbEntities()) { DateTime _now = DateTime.Now; Model.eLearning.Group _group = new Model.eLearning.Group() { Name = model.Name, CreatedBy = model.CreatedBy, CreatedDate = _now, UpdatedBy = model.UpdatedBy, IsVisible = true, EnrollmentCode = model.EnrollmentCode, Description = model.Description, }; _db.Groups.Add(_group); _db.SaveChanges(); return(Ok(_group.Id)); } }