示例#1
0
        // 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));
            }
        }
示例#2
0
        // 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 }));
        }
示例#3
0
        // GET api/<controller>
        public List <Usersdata> Get()
        {
            List <Usersdata> emplist = new List <Usersdata>();

            using (callcenterEntities db = new callcenterEntities())
            {
                var results = db.userinfoes.ToList();

                /*var results = db.GetAllUsers(0, "").ToList();
                 * //var results = db.sp_InsUpdDelEmployee(0, "", "", "", "", "", "Get").ToList(); */
                foreach (var result in results)
                {
                    var employee = new Usersdata()
                    {
                        UserId      = result.UserId,
                        LoginName   = result.LoginName,
                        UserEmail   = result.UserEmail,
                        UserName    = result.UserName,
                        IsActive    = result.IsActive,
                        IsAdmin     = result.IsAdmin,
                        CanEdit     = result.CanEdit,
                        CanFilter   = result.CanFilter,
                        CanNavigate = result.CanNavigate
                    };
                    emplist.Add(employee);
                }
                return(emplist);
            }
        }