コード例 #1
0
        public UsersModel getUser([FromUri] int userID)
        {
            TaskManagerRepository tmRep = new TaskManagerRepository();
            User_Tbl userDb             = tmRep.getUser(userID);

            return(_modelFactory.getUsersModel(userDb));
        }
コード例 #2
0
        public IHttpActionResult editUser([FromBody] UsersModel user)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest("Not a valid data"));
            }
            try
            {
                TaskManagerRepository tmRep = new TaskManagerRepository();

                User_Tbl userDb = tmRep.getUser(user.UserId);

                if (userDb != null)
                {
                    userDb.First_Name  = user.FirstName;
                    userDb.Last_Name   = user.LastName;
                    userDb.Employee_ID = Convert.ToInt32(user.EmpID);
                    string  result = "{'UserID': " + tmRep.editUser(userDb) + "}";
                    JObject json   = JObject.Parse(result);
                    return(Ok <JObject>(json));
                }
                else
                {
                    return(BadRequest("Error occurred during data update in editUser"));
                }
            }
            catch (Exception ex)
            {
                return(BadRequest("Error occurred in editUser :" + ex.StackTrace));
            }
        }