Пример #1
0
        public IHttpActionResult EditStudent([FromBody] SRStudentEditViewModel student)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    //var editStudent = Mapper.Map<SRStudent>(student);
                    var currentRecord = _strepo.Find(student.RecordID);
                    //editStudent.StatusID = 1;
                    student.StudentID = (student.StudentID == null) ? Convert.ToString(Guid.NewGuid()) : student.StudentID;
                    //editStudent.GlobalID = currentRecord.GlobalID;
                    student.AuditUserID = User.Identity.Name;
                    //Save to database
                    _strepo.Edit2(currentRecord, student);
                    _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 }));
        }
Пример #2
0
 public IHttpActionResult EditScholarship([FromBody] SRStudentEditViewModel scholarship)
 {
     try
     {
         if (ModelState.IsValid)
         {
             var currentRecord = _ischrepo.Find(scholarship.RecordID);
             scholarship.AuditUserID = User.Identity.Name;
             //Save to database
             _ischrepo.Edit2(currentRecord, scholarship);
             _ischrepo.Save();
             return(Json(new { success = true }));
         }
     }
     catch (Exception ex)
     {
         return(Json(new { Message = ex.Message }));
     }
     return(Json(new { Message = "Failed" }));
 }