Beispiel #1
0
        protected override void HandleUnauthorizedRequest(HttpActionContext actionContext)
        {
            var objResponse = new BaseResponse();

            objResponse.AddMessage("401", "Unauthorized");

            var jsonSettings = new Newtonsoft.Json.JsonSerializerSettings();

            jsonSettings.NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore;
            jsonSettings.Formatting        = Newtonsoft.Json.Formatting.Indented;
            string json = Newtonsoft.Json.JsonConvert.SerializeObject(objResponse, jsonSettings);

            var response = actionContext.Request.CreateResponse(System.Net.HttpStatusCode.Unauthorized);

            response.Content = new StringContent(json, System.Text.Encoding.UTF8, "application/json");

            actionContext.Response = response;
        }
Beispiel #2
0
        public BaseResponse Register(RegUserRequest request)
        {
            var response = new BaseResponse();


            try
            {
                if (_userRepo.Check(request.EmpId, request.First, request.Last, request.Role) != null)
                {
                    _userRepo.Register(request.EmpId, request.Password);
                    response.Success = true;
                }
                ;
            }
            catch (Exception ex)
            {
                response.AddMessage(ex.Message);
            }
            return(response);
        }