Ejemplo n.º 1
0
        // PUT api/users/5
        public ReturnValue Put(int id, [FromBody] Users value)
        {
            if (id < 0 || value == null)
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }

            if (id != value.UserSN)
            {
                throw new HttpResponseException(HttpStatusCode.BadRequest);
            }

            ReturnValue returnValue = new ReturnValue();

            try
            {
                entity.UserUpdate(id, value.PhoneHash, value.PushKey, value.DeviceID);

                returnValue.code = 0;
                returnValue.msg  = "succes";
            }
            catch
            {
                throw new HttpResponseException(HttpStatusCode.InternalServerError);
            }

            return(returnValue);
        }
Ejemplo n.º 2
0
        public ReturnValue auth([FromBody] RequestValue value)
        {
            if (value == null)
            {
                throw new HttpResponseException(HttpStatusCode.BadRequest);
            }

            try
            {
                ObjectParameter userSN     = new ObjectParameter("UserSN", typeof(long));
                ObjectParameter gUID       = new ObjectParameter("GUID", typeof(string));
                ObjectParameter hashPhone  = new ObjectParameter("HashPhone", typeof(string));
                ObjectParameter deviceID   = new ObjectParameter("DeviceID", typeof(string));
                ObjectParameter pushKey    = new ObjectParameter("PushKey", typeof(string));
                ObjectParameter createDate = new ObjectParameter("CreateDate", typeof(DateTime));
                ObjectParameter updateDate = new ObjectParameter("UpdateDate", typeof(DateTime));

                // User SN 정보 조회
                entity.UserGetInfoByToken(value.token, userSN, gUID, hashPhone, deviceID, pushKey, createDate, updateDate);

                Users user = new Users();
                user.usersn     = (long)userSN.Value;
                user.guid       = (string)gUID.Value;
                user.hashphone  = (string)hashPhone.Value;
                user.deviceid   = (string)deviceID.Value;
                user.pushkey    = (string)pushKey.Value;
                user.createdate = (DateTime)createDate.Value;
                user.updatedate = (DateTime)updateDate.Value;

                string strGUID = string.Empty;

                if ((string)hashPhone.Value == (string)value.data.hashphone)
                {
                    strGUID = Guid.NewGuid().ToString().Replace("-", string.Empty);

                    returnValue.error   = 0;
                    returnValue.message = "OK";

                    string guid   = strGUID;
                    long   usersn = (long)userSN.Value;
                    returnValue.data = new
                    {
                        usersn,
                        guid
                    };
                }
                else
                {
                    returnValue.error   = 101;
                    returnValue.message = "USER_INVALID_PHONE";
                }

                // guid 를 갱신 한다.
                entity.UserUpdate(value.token, strGUID, null, null, null);
            }
            catch (InvalidCastException)
            {
                returnValue.error   = 100;
                returnValue.message = "USER_NOT_FOUND";
            }
            catch (Exception ex)
            {
                entity.ErrorLogCreate(HttpRequestMessageHelper.GetClientIpAddress(Request), Request.RequestUri.AbsoluteUri, ex.Source, ex.TargetSite.Name, ex.Message, ex.StackTrace, JsonConvert.SerializeObject(value));;
                throw new HttpResponseException(HttpStatusCode.InternalServerError);
            }

            return(returnValue);
        }