Exemplo n.º 1
0
        public Hre_CandidateHistoryModel Post([Bind] Hre_CandidateHistoryModel model)
        {
            #region Validate
            string message       = string.Empty;
            var    checkValidate = HRM.Business.Main.Domain.ValidatorService.OnValidateData <Hre_CandidateHistoryModel>(model, "Hre_CandidateHistory", ref message);
            if (!checkValidate)
            {
                model.ActionStatus = message;
                return(model);
            }
            #endregion
            string        status = string.Empty;
            var           candidateHistoryservices = new Hre_CandidateHistoryServices();
            ActionService service = new ActionService(UserLogin);
            if (model.CandidateID != null && model.CandidateID != Guid.Empty)
            {
                var profileBycandidateID = service.GetData <Hre_ProfileEntity>(Common.DotNetToOracle(model.CandidateID.ToString()), ConstantSql.hrm_hr_sp_get_ProfileByCandidateID, ref status).FirstOrDefault();
                if (profileBycandidateID != null)
                {
                    var canhisbyprofile = service.GetData <Hre_CandidateHistoryEntity>(Common.DotNetToOracle(profileBycandidateID.ID.ToString()), ConstantSql.hrm_hr_sp_get_CandidateHistoryByProfileId, ref status).FirstOrDefault();
                    if (canhisbyprofile != null)
                    {
                        model.ID        = canhisbyprofile.ID;
                        model.ProfileID = canhisbyprofile.ProfileID;
                    }
                }
            }

            if (model.ProfileID != null && model.ProfileID != Guid.Empty)
            {
                var profile = service.GetData <Hre_ProfileEntity>(Common.DotNetToOracle(model.ProfileID.ToString()), ConstantSql.hrm_hr_sp_get_ProfileById, ref status).FirstOrDefault();

                if (profile != null)
                {
                    if (profile.CandidateID != null)
                    {
                        var canhisbyprofile = service.GetData <Hre_CandidateHistoryEntity>(Common.DotNetToOracle(profile.CandidateID.ToString()), ConstantSql.hrm_hr_sp_get_CandidateHistoryByCandidateId, ref status).FirstOrDefault();
                        if (canhisbyprofile != null)
                        {
                            model.ID          = canhisbyprofile.ID;
                            model.CandidateID = canhisbyprofile.CandidateID;
                        }
                    }
                }
            }

            return(service.UpdateOrCreate <Hre_CandidateHistoryEntity, Hre_CandidateHistoryModel>(model));
        }
Exemplo n.º 2
0
        public Hre_CandidateHistoryModel Post([Bind]Hre_CandidateHistoryModel model)
        {
            #region Validate
            string message = string.Empty;
            var checkValidate = HRM.Business.Main.Domain.ValidatorService.OnValidateData<Hre_CandidateHistoryModel>(model, "Hre_CandidateHistory", ref message);
            if (!checkValidate)
            {
                model.ActionStatus = message;
                return model;
            }
            #endregion
            string status = string.Empty;
            var candidateHistoryservices = new Hre_CandidateHistoryServices();
            ActionService service = new ActionService(UserLogin);
            if(model.CandidateID != null && model.CandidateID != Guid.Empty)
            {
                var profileBycandidateID = service.GetData<Hre_ProfileEntity>(Common.DotNetToOracle(model.CandidateID.ToString()), ConstantSql.hrm_hr_sp_get_ProfileByCandidateID, ref status).FirstOrDefault();
                if (profileBycandidateID != null)
                {
                    var canhisbyprofile = service.GetData<Hre_CandidateHistoryEntity>(Common.DotNetToOracle(profileBycandidateID.ID.ToString()), ConstantSql.hrm_hr_sp_get_CandidateHistoryByProfileId, ref status).FirstOrDefault();
                    if (canhisbyprofile != null)
                    {
                        model.ID = canhisbyprofile.ID;
                        model.ProfileID = canhisbyprofile.ProfileID;
                    }
                }
            }

            if (model.ProfileID != null && model.ProfileID != Guid.Empty)
            {
                var profile = service.GetData<Hre_ProfileEntity>(Common.DotNetToOracle(model.ProfileID.ToString()), ConstantSql.hrm_hr_sp_get_ProfileById, ref status).FirstOrDefault();

                if (profile != null)
                {
                    if(profile.CandidateID != null)
                    {
                        var canhisbyprofile = service.GetData<Hre_CandidateHistoryEntity>(Common.DotNetToOracle(profile.CandidateID.ToString()), ConstantSql.hrm_hr_sp_get_CandidateHistoryByCandidateId, ref status).FirstOrDefault();
                        if (canhisbyprofile != null)
                        {
                            model.ID = canhisbyprofile.ID;
                            model.CandidateID = canhisbyprofile.CandidateID;
                        }
                    }
                }
            }

            return service.UpdateOrCreate<Hre_CandidateHistoryEntity, Hre_CandidateHistoryModel>(model);
        }