Exemple #1
0
        public ApiResponse <string> InsertResultDetailFlightAttendant(List <ResultDetailFlightAttendantRequestViewModels> data, ClientContext clientContext)
        {
            var apiResponse = new ApiResponse <string>();
            var arrMessage  = new List <string>();

            try
            {
                var res = new SPRespository(clientContext, Utils.BuildUrlList(clientContext, ListSPs.ListResultDetailFlightAttendant));
                foreach (var x in data)
                {
                    try
                    {
                        var newItem = new ResultDetailFlightAttendantSpModels(res, null)
                        {
                            Result   = x.Result,
                            Avarage  = x.Avarage,
                            Note     = x.Note,
                            Deadline = x.Deadline
                        };
                        if (x.EmployeeCode != null)
                        {
                            newItem.EmployeeCode = new FieldLookupValue
                            {
                                LookupId = x.EmployeeCode.LookupId
                            }
                        }
                        ;
                        if (x.Assessor != null)
                        {
                            newItem.Assessor = new FieldLookupValue
                            {
                                LookupId = x.Assessor.LookupId
                            }
                        }
                        ;
                        res.AddOrUpdate(newItem);
                    }
                    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);
            }
        }
Exemple #2
0
        public ApiResponse <string> InsertProfile(List <FlightAttendantProfileRequestViewModels> data, ClientContext clientContext)
        {
            var apiResponse = new ApiResponse <string>();
            var arrMessage  = new List <string>();

            try
            {
                var res = new SPRespository(clientContext, Utils.BuildUrlList(clientContext, ListSPs.ListFlightAttendantProfile));
                foreach (var x in data)
                {
                    try
                    {
                        var newItem = new FlightAttendantProfileSpModels(res, null)
                        {
                            WorkingDate     = x.WorkingDate,
                            FlightCode      = x.FlightCode,
                            FlightDate      = x.FlightDate,
                            FlightTimeUTC   = x.FlightTimeUTC,
                            FlightTimeLocal = x.FlightTimeLocal,
                            Departure       = x.Departure,
                            Destination     = x.Destination,
                            DutyCode        = x.DutyCode,
                            CrewId          = x.CrewId,
                            EmployeeMission = x.EmployeeMission
                        };
                        newItem.FlightAttendantCode = new FieldLookupValue
                        {
                            LookupId = x.FlightAttendantCodeId
                        };
                        res.AddOrUpdate(newItem);
                    }
                    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);
            }
        }
        public ApiResponse <string> InsertWorkingTime(List <WorkingTimeRequestModels> data, ClientContext clientContext)
        {
            var apiResponse = new ApiResponse <string>();
            var arrMessage  = new List <string>();

            try
            {
                var res = new SPRespository(clientContext, Utils.BuildUrlList(clientContext, ListSPs.ListWorkingTime));
                foreach (var x in data)
                {
                    try
                    {
                        var newItem = new WorkingTimeSpModels(res, null)
                        {
                            Title            = x.Title,
                            ShiftCode        = x.ShiftCode,
                            IncomeTime       = x.IncomeTime,
                            OutcomeTime      = x.OutcomeTime,
                            DetailDepartment = x.DetailDepartment
                        };
                        if (x.DepartmentId > 0)
                        {
                            newItem.Department = new FieldLookupValue
                            {
                                LookupId = x.DepartmentId,
                            }
                        }
                        ;
                        res.AddOrUpdate(newItem);
                    }
                    catch (Exception e)
                    {
                        arrMessage.Add(e.Message);
                        apiResponse.ErrorType    = 400;
                        apiResponse.ErrorMessage = arrMessage;
                    }
                }
                return(apiResponse);
            }
            catch (Exception e)
            {
                arrMessage.Add(e.Message);
                apiResponse.ErrorType    = 400;
                apiResponse.ErrorMessage = arrMessage;
                return(apiResponse);
            }
        }
Exemple #4
0
        public ApiResponse <string> InsertFlightAttendantTitle(List <FlightAttendantTitleRequestViewModels> data, ClientContext clientContext)
        {
            var apiResponse = new ApiResponse <string>();
            var arrMessage  = new List <string>();

            try
            {
                var res = new SPRespository(clientContext, Utils.BuildUrlList(clientContext, ListSPs.ListFlightAttendantTitle));
                foreach (var x in data)
                {
                    try
                    {
                        var newItem = new FlightAttendantTitleSpModels(res, null)
                        {
                            EmployeeCode  = x.EmployeeCode,
                            EmployeeName  = x.EmployeeName,
                            PositionCode  = x.PositionCode,
                            PositionName  = x.PositionName,
                            EffectiveDate = x.EffectiveDate
                        };
                        res.AddOrUpdate(newItem);
                    }
                    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);
            }
        }
Exemple #5
0
        public ApiResponse <string> InsertTitleTemplate(List <TitleTemplateRequestViewModels> data, ClientContext clientContext)
        {
            var apiResponse = new ApiResponse <string>();
            var arrMessage  = new List <string>();

            try
            {
                var res = new SPRespository(clientContext, Utils.BuildUrlList(clientContext, ListSPs.ListTitleTemplate));
                foreach (var x in data)
                {
                    try
                    {
                        var newItem = new TitleTemplateSpModels(res, null)
                        {
                            Title = x.Title,
                            Code  = x.Code,
                        };
                        res.AddOrUpdate(newItem);
                    }
                    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);
            }
        }
Exemple #6
0
        public ApiResponse <string> InsertTimeKeeping(List <TimeKeepingInsertModels> data, ClientContext clientContext)
        {
            var apiResponse = new ApiResponse <string>();
            var arrMessage  = new List <string>();

            try
            {
                var res = new SPRespository(clientContext, Utils.BuildUrlList(clientContext, ListSPs.ListTimeKeeping));
                foreach (var x in data)
                {
                    try
                    {
                        var newItem = new TimeKeepingSPModels(res, null)
                        {
                            DeviceName          = x.device_name,
                            UserId              = x.user_id,
                            TimeKeepingDateTime = Convert.ToDateTime(x.date + " " + x.time),
                            CreateTimeAt        = x.created_at,
                            UpdatedTimeAt       = x.updated_at,
                            EmployeeEmail       = x.user_email
                        };
                        res.AddOrUpdate(newItem);
                    }
                    catch (Exception e)
                    {
                        arrMessage.Add(e.Message);
                        apiResponse.ErrorType    = 400;
                        apiResponse.ErrorMessage = arrMessage;
                    }
                }
                return(apiResponse);
            }
            catch (Exception e)
            {
                arrMessage.Add(e.Message);
                apiResponse.ErrorType    = 400;
                apiResponse.ErrorMessage = arrMessage;
                return(apiResponse);
            }
        }
Exemple #7
0
        public ApiResponse <string> InsertDepartment(List <DepartmentRequestModels> data, ClientContext clientContext)
        {
            var apiResponse = new ApiResponse <string>();
            var arrMessage  = new List <string>();

            try
            {
                var res = new SPRespository(clientContext, Utils.BuildUrlList(clientContext, ListSPs.ListDepartment));
                foreach (var x in data)
                {
                    try
                    {
                        var newItem = new DepartmentSPModels(res, null)
                        {
                            Title = x.Title,
                            Code  = x.Code
                        };
                        res.AddOrUpdate(newItem);
                    }
                    catch (Exception e)
                    {
                        arrMessage.Add(e.Message);
                        apiResponse.ErrorType    = 400;
                        apiResponse.ErrorMessage = arrMessage;
                    }
                }
                return(apiResponse);
            }
            catch (Exception e)
            {
                arrMessage.Add(e.Message);
                apiResponse.ErrorType    = 400;
                apiResponse.ErrorMessage = arrMessage;
                return(apiResponse);
            }
        }
Exemple #8
0
        public ApiResponse <string> InsertResultFlight(List <ResultFlightRequestViewModels> data, ClientContext clientContext)
        {
            var apiResponse = new ApiResponse <string>();
            var arrMessage  = new List <string>();

            try
            {
                var res = new SPRespository(clientContext, Utils.BuildUrlList(clientContext, ListSPs.ListResultFlight));
                foreach (var x in data)
                {
                    try
                    {
                        var newItem = new ResultFlightSpModels(res, null)
                        {
                            IdentifyName = x.IdentifyName,
                            FullName     = x.FullName,
                            PositonName  = x.PositonName,
                            Result       = x.Result,
                            Avarage      = x.Avarage,
                            Note         = x.Note,
                        };
                        if (x.StaffId != null)
                        {
                            newItem.StaffId = new FieldLookupValue
                            {
                                LookupId = x.StaffId.LookupId,
                            }
                        }
                        ;
                        if (x.Creator != null)
                        {
                            newItem.Creator = new FieldLookupValue
                            {
                                LookupId = x.Creator.LookupId,
                            }
                        }
                        ;
                        res.AddOrUpdate(newItem);
                    }
                    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);
            }
        }
Exemple #9
0
        public ApiResponse <string> InsertReviewCategory(List <ReviewCategoryRequestViewModels> data, ClientContext clientContext)
        {
            var apiResponse = new ApiResponse <string>();
            var arrMessage  = new List <string>();

            try
            {
                var res = new SPRespository(clientContext, Utils.BuildUrlList(clientContext, ListSPs.ListReviewCategory));
                foreach (var x in data)
                {
                    try
                    {
                        var newItem = new ReviewCategorySpModels(res, null)
                        {
                            Phase = x.Phase,
                            EvaluationCriteria = x.EvaluationCriteria,
                            Satisfy            = x.Satisfy,
                            NotSatisfy         = x.NotSatisfy,
                            NeedImprove        = x.NeedImprove,
                            Detail             = x.Detail,
                            EffectiveDate      = x.EffectiveDate,
                            EffectiveToDate    = x.EffectiveToDate,
                            Status             = x.Status
                        };
                        if (x.ReviewCategoryId != null)
                        {
                            newItem.ReviewCategoryId = new FieldLookupValue
                            {
                                LookupId = x.ReviewCategoryId.LookupId
                            }
                        }
                        ;
                        if (x.CreatedUser != null)
                        {
                            newItem.CreatedUser = new FieldLookupValue
                            {
                                LookupId = x.CreatedUser.LookupId
                            }
                        }
                        ;
                        if (x.BeReviewedUser != null)
                        {
                            newItem.BeReviewedUser = new FieldLookupValue
                            {
                                LookupId = x.BeReviewedUser.LookupId
                            }
                        }
                        ;
                        res.AddOrUpdate(newItem);
                    }
                    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);
            }
        }
        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);
            }
        }
        public ApiResponse <string> UpdateHrByEmail(HrUpdateRequestModels data, ClientContext clientContext)
        {
            var apiResponse = new ApiResponse <string>();
            var arrMessage  = new List <string>();

            try
            {
                var hrRes = new SPRespository(clientContext, Utils.BuildUrlList(clientContext, ListSPs.ListHr));
                var query = new CamlQuery {
                    ViewXml = string.Format(HrView.GetHr.GetByCompanyEmail, data.Email)
                };
                var hrItemQuery = hrRes.Query(query, (item) => new HrSpModels(hrRes, item)).ToArray();
                if (hrItemQuery.Length == 0)
                {
                    apiResponse.ErrorMessage = new[] { Message.MessageApi.NoItem };
                    apiResponse.ErrorType    = 400;
                    return(apiResponse);
                }
                foreach (var itemQuery in hrItemQuery)
                {
                    itemQuery.EmployeeCode         = data.HrModels.EmployeeCode;
                    itemQuery.FullName             = data.HrModels.FullName;
                    itemQuery.CompanyEmail         = data.HrModels.CompanyEmail;
                    itemQuery.NickName             = data.HrModels.NickName;
                    itemQuery.PersonalPhone        = data.HrModels.PersonalPhone;
                    itemQuery.PersonalEmail        = data.HrModels.PersonalEmail;
                    itemQuery.DateOfBirth          = data.HrModels.DateOfBirth;
                    itemQuery.Relationship         = data.HrModels.Relationship;
                    itemQuery.PermanetAddress      = data.HrModels.PermanetAddress;
                    itemQuery.TemporaryAddress     = data.HrModels.TemporaryAddress;
                    itemQuery.Group                = data.HrModels.Group;
                    itemQuery.Department           = data.HrModels.Department;
                    itemQuery.WorkingAddress       = data.HrModels.WorkingAddress;
                    itemQuery.Role                 = data.HrModels.Role;
                    itemQuery.StartingDate         = data.HrModels.StartingDate;
                    itemQuery.Status               = data.HrModels.Status;
                    itemQuery.WorkingPhone         = data.HrModels.WorkingPhone;
                    itemQuery.Level                = data.HrModels.Level;
                    itemQuery.LineManager          = data.HrModels.LineManager;
                    itemQuery.LatestChangeDate     = data.HrModels.LatestChangeDate;
                    itemQuery.ChangedModified      = data.HrModels.ChangedModified;
                    itemQuery.ExpiredDate          = data.HrModels.ExpiredDate;
                    itemQuery.Experience           = data.HrModels.Experience;
                    itemQuery.Education            = data.HrModels.Education;
                    itemQuery.CompanyAssets        = data.HrModels.CompanyAssets;
                    itemQuery.LeavingReason        = data.HrModels.LeavingReason;
                    itemQuery.Taxno                = data.HrModels.Taxno;
                    itemQuery.SocialInsurantNumber = data.HrModels.SocialInsurantNumber;
                    itemQuery.LeavingAllowedNumber = data.HrModels.LeavingAllowedNumber;
                    itemQuery.TicketsNumberIssued  = data.HrModels.TicketsNumberIssued;
                    hrRes.AddOrUpdate(itemQuery);
                }
                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);
            }
        }