public ActionResult Login(Login log)
        {
            client = new ServiceClientWrapper();

            var baseAddress = "http://localhost:57108/api/Employee/Login";

            var parameters = new Dictionary <string, string>
            {
                { "email", log.email },
                { "password", log.password }
            };
            var result = client.Send(new ServiceRequest {
                BaseAddress = baseAddress, HttpProtocol = Protocols.HTTP_POST, RequestParameters = parameters
            });
            var success = JsonConvert.DeserializeObject <bool>(result.Response);

            if (success)
            {
                return(Redirect("~/Home/Index"));
            }
            else
            {
                return(Redirect("~/Employee/Create"));
            }
        }
        public ActionResult Create(Employee emp)
        {
            client = new ServiceClientWrapper();

            if (ModelState.IsValid)
            {
                var baseAddress = "http://localhost:57108/api/Employee/RegisterEmployee";

                var parameters = new Dictionary <string, string>
                {
                    { "accountId", emp.employeeId },
                    { "employeeId", emp.employeeId },
                    { "employeeName", emp.employeeName },
                    { "email", emp.email },
                    { "password", emp.password }
                };

                var result = client.Send(new ServiceRequest {
                    BaseAddress = baseAddress, HttpProtocol = Protocols.HTTP_POST, RequestParameters = parameters
                });
                var success = JsonConvert.DeserializeObject <Boolean>(result.Response);

                if (success)
                {
                    return(Redirect("~/Employee/Create"));
                }
                else
                {
                    TempData["errorMsg"] = "<script>alert('Invalid Data')</script>";
                }
            }

            return(View());
        }
Example #3
0
        public static string SavePic(Picture picture)
        {
            ServiceClientWrapper client = new ServiceClientWrapper();

#if DEBUG
            var Address = Config.BASE_ADDRESS_DEBUG + "Image/SavePicture";
#else
            var Address = Config.BASE_ADDRESS + "Image/SavePicture";
#endif
            var result = client.Send(new ServiceRequest {
                BaseAddress = Address, HttpProtocol = Protocols.HTTP_POST, Body = JsonConvert.SerializeObject(picture)
            });
            var path = JsonConvert.DeserializeObject <string>(result.Response);

            return(path);
        }
Example #4
0
        public void DeletePic(string path)
        {
            ServiceClientWrapper client = new ServiceClientWrapper();

#if DEBUG
            var Address = Config.BASE_ADDRESS_DEBUG + "Image/DeletePicture";
#else
            var Address = Config.BASE_ADDRESS + "Image/DeletePicture";
#endif
            var Params = new Dictionary <string, string>
            {
                { "path", path }
            };

            var result = client.Send(new ServiceRequest {
                BaseAddress = Address, HttpProtocol = Protocols.HTTP_POST, RequestParameters = Params
            });
            //var status = JsonConvert.DeserializeObject<int>(result.Response);
        }
Example #5
0
        public static Picture GetPic(string path)
        {
            ServiceClientWrapper client = new ServiceClientWrapper();

#if DEBUG
            var Address = Config.BASE_ADDRESS_DEBUG + "Image/GetPicture";
#else
            var Address = Config.BASE_ADDRESS + "Image/GetPicture";
#endif
            var Params = new Dictionary <string, string>
            {
                { "path", path }
            };

            var result = client.Send(new ServiceRequest {
                BaseAddress = Address, HttpProtocol = Protocols.HTTP_GET, RequestParameters = Params
            });
            var picture = JsonConvert.DeserializeObject <Picture>(result.Response);

            return(picture);
        }