Beispiel #1
0
        public IHttpActionResult Post([FromBody] SRStudentNewViewModel student)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var newStudent = Mapper.Map <SRStudent>(student);
                    newStudent.StatusID    = 1;
                    newStudent.StudentID   = (newStudent.StudentID == null) ? Convert.ToString(Guid.NewGuid()) : newStudent.StudentID;
                    newStudent.GlobalID    = Guid.NewGuid();
                    newStudent.AuditUserID = User.Identity.Name;
                    //Save to database
                    _strepo.Insert(newStudent);
                    _strepo.Save();
                    return(Json(new { success = true }));
                    //Json(Mapper.Map<SRStudentNewViewModel>(newStudent));
                }
            }
            catch (Exception ex)
            {
                //return request.CreateResponse(HttpStatusCode.BadRequest, GetErrorMessages());
                // Response.StatusCode = (int)HttpStatusCode.BadRequest;
                return(Json(new { Message = ex.Message }));
            }

            // Response.StatusCode = (int)HttpStatusCode.BadRequest;
            return(Json(new { Message = "Failed", ModelState = ModelState }));
        }
Beispiel #2
0
 // POST: api/StService
 public void Post(SRStudentNewViewModel student)
 {
 }