public IHttpActionResult Post(EmployeeViewModel emp)
 {
     try
     {
         emp.Create();
         return(Ok(emp));
     }
     catch (Exception e)
     {
         return(BadRequest("Create failed - " + e.Message));
     }
 }
示例#2
0
 public IHttpActionResult Post(EmployeeViewModel emp)
 {
     try
     {
         emp.Create();
         return(Ok("Employee " + emp.Lastname + " created"));
     }
     catch (Exception ex)
     {
         return(BadRequest("Retrieve failed - " + ex.Message));
     }
 }
示例#3
0
 public IHttpActionResult Post(EmployeeViewModel emp)
 {
     try
     {
         emp.Create();
         string msg = emp.Lastname + " has been created";
         return(Ok(msg));
     }
     catch (Exception ex)
     {
         return(BadRequest("Create failed - " + ex.Message));
     }
 }
示例#4
0
        public void TestCreateShouldReturnNewId()// test create
        {
            EmployeeViewModel vm = new EmployeeViewModel();

            vm.Title        = "Mr.";
            vm.Firstname    = "Nick";
            vm.Lastname     = "Vail";
            vm.Phoneno      = "(555)555-4566";
            vm.Email        = "*****@*****.**";
            vm.Version      = 1;
            vm.DepartmentId = departId;
            vm.Create();
            Assert.IsTrue(vm.Id.Length == 24);
        }
示例#5
0
        public void TestCreateShouldReturnNewId()
        {
            EmployeeViewModel vm = new EmployeeViewModel();

            vm.Title        = "Mr.";
            vm.Firstname    = "Jake";
            vm.Lastname     = "Test";
            vm.Phoneno      = "(555)111-1111";
            vm.Email        = "*****@*****.**";
            vm.Version      = 1;
            vm.DepartmentId = did;
            vm.Create();

            Assert.IsTrue(vm.Id.Length == 24);
        }
示例#6
0
        public void TestCreateShouldReturnNewId()
        {
            EmployeeViewModel vm = new EmployeeViewModel();

            vm.Title        = "Mr.";
            vm.Firstname    = "Evan";
            vm.Lastname     = "Test";
            vm.Phoneno      = "(555)555-5555";
            vm.Email        = "*****@*****.**";
            vm.Version      = 1;
            vm.DepartmentId = did;
            vm.Create();
            //12 byte hex = 24 byte string
            Assert.IsTrue(vm.Id.Length == 24);
        }
示例#7
0
 public IHttpActionResult Create(EmployeeViewModel emp)
 {
     try
     {
         emp.Create();
         if (emp.Id != "")
         {
             return(Ok("Ok! Employee " + emp.Lastname + " Created!"));
         }
         else
         {
             return(Ok("Error! Employee could not be created"));
         }
     }
     catch (Exception ex)
     {
         return(BadRequest("Create Failed - Contact Tech Support"));
     }
 }
示例#8
0
        public void EmployeeVMCreateAndDeleteShouldReturnTrue()
        {
            bool deleteOk        = false;
            EmployeeViewModel vm = new EmployeeViewModel();

            //use an existing departmentid here
            vm.DepartmentId = "564107b33dd4ed255425f4c5";
            // and some hardcoded data
            vm.Email     = "*****@*****.**";
            vm.Firstname = "Some";
            vm.Lastname  = "Employee";
            vm.Phoneno   = "(555)555-5555";
            vm.Title     = "Mr. ";
            vm.Create();
            if (vm.Id.Length == 24) //new id's are a 24 byte hex string
            {
                deleteOk = vm.Delete();
            }
            Assert.IsTrue(deleteOk);
        }