// POST api/<controller>
        public async Task <IHttpActionResult> AddUserToGroup(UserGroupViewModel GVM)
        {
            ResultClassToken result = new ResultClassToken();

            try
            {
                var token = HttpContext.Current.Request.Headers["Authorization"].Replace("bearer ", "");

                var mm = ApiMessage.AddUserToGroup(GVM);
                if (mm != null)
                {
                    result.Code = (int)HttpStatusCode.OK;
                    result.Msg  = ap.Success;
                }
                else
                {
                    result.Code = (int)HttpStatusCode.NonAuthoritativeInformation;
                    result.Msg  = ap.MessageNoData;
                }
                if (updatetoken)
                {
                    token = result.AccessToken = accessToken;
                }
                else
                {
                    result.AccessToken = "";
                }
                return(Ok(result));
            }
            catch (Exception ex)
            {
                return(Ok(ApiEx.FireException(result, ex)));
            }
        }
        // POST api/<controller>
        public async Task <IHttpActionResult> messagerequest(MessageRequestModel MM)
        {
            try
            {
                ResultClassToken result = new ResultClassToken();

                var userdata = ApiMessage.messagerequest(MM);
                if (userdata != null)
                {
                    result.Code = (int)HttpStatusCode.OK;
                    result.Msg  = ap.Success;
                }
                else
                {
                    result.Code = (int)HttpStatusCode.NonAuthoritativeInformation;
                    result.Msg  = ap.GlobalError;
                }
                if (updatetoken)
                {
                    result.AccessToken = accessToken;
                }
                else
                {
                    result.AccessToken = "";
                }
                return(Ok(result));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public ResultClassToken ChangePassword(ChangePasswordModel cP, string token)
        {
            ResultClassToken rc = new ResultClassToken();

            using (LystenEntities db = new LystenEntities())
            {
                var pwd = SecutiryServices.EncodePasswordToBase64(cP.CurrentPassword);

                var data = db.User_Master.Where(x => x.Password == pwd && x.Id == cP.UserId).FirstOrDefault();
                if (data != null)
                {
                    data.Password        = SecutiryServices.EncodePasswordToBase64(cP.NewPassword);
                    db.Entry(data).State = EntityState.Modified;
                    db.SaveChanges();
                    rc.Code = (int)HttpStatusCode.OK;
                    rc.Msg  = ap.Success;
                    //objresult.Data = model;
                }
                else
                {
                    rc.Code = (int)HttpStatusCode.NotFound;
                    rc.Msg  = ap.CurrentPaasswordNotSame;
                    //objresult.Data = model;
                }
            }
            return(rc);
        }
        private ApiUserServices US;                //= new ApiUserServices();

        public ApiCommonServices()
        {
            objresult       = new ResultClass();
            objresultCommon = new ResultClassCommon();
            objresultToken  = new ResultClassToken();
            es = new EmailServices();
            ap = new ApiMessageFormat();
            US = new ApiUserServices();
        }
Beispiel #5
0
        // PUT api/<controller>/5
        public async Task <IHttpActionResult> ChangePassword(ChangePasswordModel CP)
        {
            ResultClassToken result = new ResultClassToken();
            var token = HttpContext.Current.Request.Headers["Authorization"].Replace("bearer ", "");

            result = ApiCommon.ChangePassword(CP, token);
            if (updatetoken)
            {
                token = result.AccessToken = accessToken;
            }
            else
            {
                result.AccessToken = "";
            }
            return(Ok(result));
        }
Beispiel #6
0
 public dynamic FireException(ResultClassToken result, Exception ex)
 {
     result.Code = (int)HttpStatusCode.InternalServerError;
     result.Msg  = ex.Message;
     return(result);
 }