예제 #1
0
        /// <summary>
        /// received id
        /// created HRentityId entity and send it to GEtEmployeeById function
        /// In the response, the function receives HREntity Model
        /// </summary>
        /// <param name="employee"></param>
        /// <returns>HREntity Model</returns>
        public Models.EmployeeHRModel GetHREmployeeById(HREntityID employee)
        {
            HREntity       deserialized = null;
            string         baseUrl      = ConfigurationManager.ConnectionStrings["HRServerName"].ConnectionString;
            HttpWebRequest request      = Utils.Functionals.Communicator.PostReques <HREntity>(baseUrl + DestinationNames.GetHREmployeeId, "POST", employee);

            try
            {
                WebResponse response = request.GetResponse();
                deserialized = Utils.Functionals.Communicator.ParseResponse <HREntity>(response.GetResponseStream());
            }
            catch (WebException ex)
            {
                Logger.Logger.Addlog(ex.InnerException + " " + ex.Message);
            }

            Models.EmployeeHRModel hrmodel = new EmployeeHRModel();
            hrmodel.Id           = deserialized.Id;
            hrmodel.Name         = deserialized.Name;
            hrmodel.LastName     = deserialized.LastName;
            hrmodel.Passport     = deserialized.Passport;
            hrmodel.Phone        = deserialized.Phone;
            hrmodel.SocialId     = deserialized.SocialId;
            hrmodel.Address      = deserialized.Address;
            hrmodel.DateOfBirth  = deserialized.DateOfBirth;
            hrmodel.DateOfHiring = deserialized.DateOfHiring;
            hrmodel.Description  = deserialized.Description;

            return(hrmodel);
        }
예제 #2
0
        /// <summary>
        /// created HttpRequest called GEtEmployeesHR function
        /// deserialized HREntitiess model stream, convert datamodel to model
        /// </summary>
        /// <returns>HREmployees Model</returns>
        public Models.EmployeesHRModel GetEmployeesHR()
        {
            HREntities     employees = new HREntities();
            string         baseUrl   = ConfigurationManager.ConnectionStrings["HRServerName"].ConnectionString;
            HttpWebRequest req       = Utils.Functionals.Communicator.GetRequest(baseUrl + DestinationNames.GetHREmployees, "GET");

            try
            {
                HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
                employees = Utils.Functionals.Communicator.ParseResponse <HREntities>(resp.GetResponseStream());
            }
            catch (WebException ex)
            {
                Logger.Logger.Addlog(ex.Message + ',' + ex.Status);
            }
            EmployeesHRModel hremployees = new EmployeesHRModel();

            foreach (HREntity el in employees.ListOfEntities)
            {
                Models.EmployeeHRModel item = new EmployeeHRModel();
                item.Id       = el.Id;
                item.Name     = el.Name;
                item.LastName = el.LastName;
                item.Address  = el.Address;
                item.Phone    = el.Phone;
                hremployees.ListOFEmployee.Add(item);
            }
            return(hremployees);
        }
예제 #3
0
        /// <summary>
        /// received Employee Model, convert it to datamodel
        /// and send to HR layer
        /// </summary>
        /// <param name="HREntity"></param>
        /// <returns></returns>
        public string PostEmployee(EmployeeHRModel HREntity)
        {
            HREntities entitiy = new HREntities();
            //Convert Model to Entity
            HREntity hrentiy = new HREntity();
            {
                hrentiy.Id            = HREntity.Id;
                hrentiy.Name          = HREntity.Name;
                hrentiy.LastName      = HREntity.LastName;
                hrentiy.DateOfBirth   = HREntity.DateOfBirth;
                hrentiy.DateOfHiring  = HREntity.DateOfHiring;
                hrentiy.Address       = HREntity.Address;
                hrentiy.Description   = HREntity.Description;
                hrentiy.MaritalStatus = HREntity.MaritalStatus;
                hrentiy.Passport      = HREntity.Passport;
                hrentiy.Phone         = HREntity.Phone;
                hrentiy.SocialId      = HREntity.SocialId;
                entitiy.ListOfEntities.Add(hrentiy);
            }
            string         baseUrl = ConfigurationManager.ConnectionStrings["HRServerName"].ConnectionString;
            HttpWebRequest request = Utils.Functionals.Communicator.PostReques <HREntities>(baseUrl + DestinationNames.AddHREmployee, @"POST", entitiy);

            return(Utils.Functionals.Communicator.GetResponse(request.GetResponse()));
        }