public HttpResponseMessage Post([FromBody] GroupsViewModel group) { if (ModelState.IsValid) { int userId = Convert.ToInt32(this.User.FindFirstValue(ClaimTypes.Name)); int coorid = _teacher.GetTeacherId(userId); var tempEnrol = AutoMapper.Mapper.Map <Groups>(group); tempEnrol.createdBy = coorid; _group.InsertGroup(tempEnrol); var response = new HttpResponseMessage() { StatusCode = HttpStatusCode.OK }; return(response); } else { var response = new HttpResponseMessage() { StatusCode = HttpStatusCode.BadRequest }; return(response); } }
public HttpResponseMessage Post([FromBody] ProjectViewModel project) { if (ModelState.IsValid) { int userId = Convert.ToInt32(this.User.FindFirstValue(ClaimTypes.Name)); int coorid = _teacher.GetTeacherId(userId); var tempEnrol = AutoMapper.Mapper.Map <Project>(project); tempEnrol.createdBy = coorid; tempEnrol.IssueDate = DateTime.Today; _project.InsertProject(tempEnrol); var response = new HttpResponseMessage() { StatusCode = HttpStatusCode.OK }; return(response); } else { var response = new HttpResponseMessage() { StatusCode = HttpStatusCode.BadRequest }; return(response); } }
public HttpResponseMessage Post([FromBody] Assessment assessment) { if (ModelState.IsValid) { int userId = Convert.ToInt32(this.User.FindFirstValue(ClaimTypes.Name)); int coorid = _teacher.GetTeacherId(userId); // var tempEnrol = AutoMapper.Mapper.Map<Assessment>(assessment); assessment.createdBy = coorid; assessment.createdDate = DateTime.Today; _assessment.InsertAssessment(assessment); var response = new HttpResponseMessage() { StatusCode = HttpStatusCode.OK }; return(response); } else { var response = new HttpResponseMessage() { StatusCode = HttpStatusCode.BadRequest }; return(response); } }