예제 #1
0
        public bool AddProspect(StudentProspect studentProspect)
        {
            studentProspect.Status = studentProspect.Status.ToUpper();
            if (!studentProspect.Status.Equals("ACTIVE") && !studentProspect.Status.Equals("PASSIVE"))
            {
                throw new Exception("Status should be Active or Passive");
            }
            if (studentProspect.DateOfBirth > DateTime.Now)
            {
                throw new Exception("Date Of Birth can't be more than present day");
            }
            TimeSpan difference = DateTime.Now.Subtract(studentProspect.DateOfBirth);
            var      days       = difference.Days;

            if ((days / 365) >= 5)
            {
                _Stafflist.StudentProspects.Add(studentProspect);
                _Stafflist.SaveChanges();
                return(true);
            }
            else
            {
                throw new Exception("Age should be more than 5 years");
            }
        }
 public ActionResult AddProspect(StudentProspect StudentProspect)
 {
     try
     {
         bool result = this._IStaffService.AddProspect(StudentProspect);
         if (result)
         {
             return(Ok());
         }
         else
         {
             return(NotFound());
         }
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
     finally
     {
     }
 }