Ejemplo n.º 1
0
        private static void GetItemModels(List <HrViewModels> listItems, HrSpModels x, ClientContext clientContext)
        {
            var itemViewModel = new HrViewModels
            {
                Id                   = x.Id,
                EmployeeCode         = x.EmployeeCode,
                FullName             = x.FullName,
                CompanyEmail         = x.CompanyEmail,
                NickName             = x.NickName,
                PersonalPhone        = x.PersonalPhone,
                PersonalEmail        = x.PersonalEmail,
                DateOfBirth          = x.DateOfBirth,
                Relationship         = x.Relationship,
                PermanetAddress      = x.PermanetAddress,
                TemporaryAddress     = x.TemporaryAddress,
                Group                = x.Group,
                Department           = x.Department,
                WorkingAddress       = x.WorkingAddress,
                Role                 = x.Role,
                StartingDate         = x.StartingDate,
                Status               = x.Status,
                WorkingPhone         = x.WorkingPhone,
                Level                = x.Level,
                LineManager          = x.LineManager,
                LatestChangeDate     = x.LatestChangeDate,
                ChangedModified      = x.ChangedModified,
                ExpiredDate          = x.ExpiredDate,
                Experience           = x.Experience,
                Education            = x.Education,
                CompanyAssets        = x.CompanyAssets,
                LeavingReason        = x.LeavingReason,
                Taxno                = x.Taxno,
                SocialInsurantNumber = x.SocialInsurantNumber
            };

            if (x.LeavingAllowedNumber != null)
            {
                itemViewModel.LeavingAllowedNumber = Convert.ToInt32(x.LeavingAllowedNumber);
            }
            if (x.TicketsNumberIssued != null)
            {
                itemViewModel.TicketsNumberIssued = Convert.ToInt32(x.TicketsNumberIssued);
            }
            listItems.Add(itemViewModel);
        }
Ejemplo n.º 2
0
        public ApiResponse <string> InsertHr(List <HrInsertModels> data, ClientContext clientContext)
        {
            var apiResponse = new ApiResponse <string>();
            var arrMessage  = new List <string>();

            try
            {
                var hrRes = new SPRespository(clientContext, Utils.BuildUrlList(clientContext, ListSPs.ListHr));
                foreach (var x in data)
                {
                    try
                    {
                        var newHr = new HrSpModels(hrRes, null)
                        {
                            EmployeeCode         = x.EmployeeCode,
                            FullName             = x.FullName,
                            CompanyEmail         = x.CompanyEmail,
                            NickName             = x.NickName,
                            PersonalPhone        = x.PersonalPhone,
                            PersonalEmail        = x.PersonalEmail,
                            DateOfBirth          = x.DateOfBirth,
                            Relationship         = x.Relationship,
                            PermanetAddress      = x.PermanetAddress,
                            TemporaryAddress     = x.TemporaryAddress,
                            Group                = x.Group,
                            Department           = x.Department,
                            WorkingAddress       = x.WorkingAddress,
                            Role                 = x.Role,
                            StartingDate         = x.StartingDate,
                            Status               = x.Status,
                            WorkingPhone         = x.WorkingPhone,
                            Level                = x.Level,
                            LineManager          = x.LineManager,
                            LatestChangeDate     = x.LatestChangeDate,
                            ChangedModified      = x.ChangedModified,
                            ExpiredDate          = x.ExpiredDate,
                            Experience           = x.Experience,
                            Education            = x.Education,
                            CompanyAssets        = x.CompanyAssets,
                            LeavingReason        = x.LeavingReason,
                            LeavingAllowedNumber = x.LeavingAllowedNumber,
                            TicketsNumberIssued  = x.TicketsNumberIssued,
                            Taxno                = x.Taxno,
                            SocialInsurantNumber = x.SocialInsurantNumber
                        };
                        hrRes.AddOrUpdate(newHr);
                    }
                    catch (Exception e)
                    {
                        arrMessage.Add(e.Message);
                        apiResponse.ErrorType    = 400;
                        apiResponse.ErrorMessage = arrMessage;
                    }
                }
                if (apiResponse.ErrorType != 400)
                {
                    apiResponse.Content = new[] { Message.MessageApi.Success }
                }
                ;
                return(apiResponse);
            }
            catch (Exception e)
            {
                arrMessage.Add(e.Message);
                apiResponse.ErrorType    = 400;
                apiResponse.ErrorMessage = arrMessage;
                return(apiResponse);
            }
        }