コード例 #1
0
        public HttpResponseMessage DeleteEmployee(HomeDeleteEmployeeParam param)
        {
            try
            {
                JsonContent validationResult;
                if (!param.ValidateParam(ModelState, out validationResult))
                {
                    return(new HttpResponseMessage()
                    {
                        Content = validationResult
                    });
                }

                HomeDeleteEmployeeParam.DeleteEmployee(ref _api, ref param);
                var listParam = new HomeListEmployeesParam()
                {
                    EmployeeID = 0
                };

                return(new HttpResponseMessage()
                {
                    Content = new StringContent(
                        JsonConvert.SerializeObject(new FrontEndResponseModel()
                    {
                        Status = 200,
                        Description = JsonConvert.SerializeObject(HomeListEmployeesParam.ListEmployee(ref _api, ref listParam))
                    }),
                        Encoding.UTF8,
                        "application/json")
                });
            }
            catch (Exception ex)
            {
                var exh = new ExceptionHelper(ref ex, true);
                return(new HttpResponseMessage()
                {
                    Content = new StringContent(
                        JsonConvert.SerializeObject(new FrontEndResponseModel()
                    {
                        Status = 500,
                        Description = exh.Message
                    }),
                        Encoding.UTF8,
                        "application/json")
                });
            }
        }
コード例 #2
0
        // I intentionally removed the token validation algorythms, session validation, and other security measures in this demo code.

        public static int DeleteEmployee(ref SimpleCrudContext api, ref HomeDeleteEmployeeParam param)
        {
            param = param.TrimAll();
            return(api.DeleteEmployee(param.EmployeeID));
        }