Пример #1
0
 public SaveResult Add(StudentModel entity)
 {
     try
     {
         ObjectParameter param1 = new ObjectParameter("studentId", entity.StudentId);
         var             result = _context.proc_Student_Insert(param1, entity.FirstName,
                                                               entity.MiddleName, entity.LastName,
                                                               entity.GenderModel.GenderId,
                                                               entity.Address1, entity.Address2,
                                                               entity.CityModel != null?entity.CityModel.CityId:(int?)null,
                                                               entity.ZipCode, entity.StateCode);
         return(new SaveResult
         {
             Id = (int)param1.Value,
             Message = "Student was created.",
             Status = "OK"
         });
     }
     catch (Exception ex)
     {
         return(new SaveResult
         {
             Id = 0,
             Message = "Error on Student Add method. " + ex.InnerException != null ? ex.InnerException.Message : ex.Message,
             Status = "ERROR"
         });
     }
 }