// Update Employee public HttpResponseMessage Put(Usersdata user) { string OutMessage = string.Empty; List <userinfo> emplist = new List <userinfo>(); if (!ModelState.IsValid) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)); } using (callcenterEntities db = new callcenterEntities()) { try { ObjectParameter Output = new ObjectParameter("responseMessage", typeof(string)); var users = db.uspAddUser(user.LoginName, Convert.ToString(user.PasswordHash), user.UserName, user.UserEmail, user.IsAdmin, user.IsActive, user.CanEdit, user.CanFilter, user.CanNavigate, Output); OutMessage = Convert.ToString(Output.Value); emplist = db.userinfoes.ToList(); } catch (DbUpdateConcurrencyException ex) { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, ex)); } } return(Request.CreateResponse(HttpStatusCode.OK, new { emplist, responsemessage = OutMessage })); }
// Insert Employee public HttpResponseMessage Post(Usersdata user) { string OutMessage = string.Empty; if (ModelState.IsValid) { using (callcenterEntities db = new callcenterEntities()) { ObjectParameter Output = new ObjectParameter("responseMessage", typeof(string)); //string mssage = string.Empty; var objresults = db.uspAddUser(user.LoginName, Convert.ToString(user.PasswordHash), user.UserName, user.UserEmail, user.IsAdmin, user.IsActive, user.CanEdit, user.CanFilter, user.CanNavigate, Output); var emplist = db.userinfoes.ToList(); OutMessage = Convert.ToString(Output.Value); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, new { emplist, responsemessage = OutMessage }); return(response); } } else { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)); } }