Exemple #1
0
        public ActionResult AddUserProfile(UserViewModel userViewModel)
        {
            ResponseOut responseOut = new ResponseOut();

            IUserBL userBL = new UserEngine();

            try
            {
                if (userViewModel != null)
                {
                    responseOut = userBL.AddUserProfile(userViewModel);
                }
                else
                {
                    responseOut.message = ActionMessage.ProbleminData;
                    responseOut.status  = ActionStatus.Fail;
                }
            }
            catch (Exception ex)
            {
                responseOut.message = ActionMessage.ApplicationException;
                responseOut.status  = ActionStatus.Fail;
            }
            return(Json(responseOut, JsonRequestBehavior.AllowGet));
        }
        public ResponseOut UploadVendorCandidate(ImportVendorCandidateViewModel data)
        {
            using (PortalEntities _context = new PortalEntities())
            {
                ResponseOut parentResponseOut = new ResponseOut();
                try
                {
                    ResponseOut vendorResponseOut = new ResponseOut();
                    //Insert or  Get Country
                    int    country_id          = _context.portal_country.Where(x => x.country_name.ToLower() == data.country.ToLower()).Select(x => x.pk_country_id).FirstOrDefault();
                    int    state_id            = _context.portal_state.Where(x => x.state_name.ToLower() == data.state.ToLower()).Select(x => x.pk_state_id).FirstOrDefault();
                    int    city_id             = _context.portal_city.Where(x => x.city_name.ToLower() == data.city.ToLower()).Select(x => x.pk_city_id).FirstOrDefault();
                    int    vendor_id           = _context.portal_user.Where(x => x.user_name.ToLower() == data.vendor_user_name.ToLower()).Select(x => x.pk_user_id).FirstOrDefault();
                    int    experience_level_id = _context.portal_experience.Where(x => x.level.ToLower() == data.experience_level.ToLower()).Select(x => x.pk_experience_level_id).FirstOrDefault();
                    string technology_id       = _context.portal_experise.Where(x => x.expertise_name.ToLower() == data.candidate_technology.ToLower()).Select(x => x.pk_expertise_id.ToString()).FirstOrDefault();
                    if (country_id == 0)
                    {
                        portal_country _country = new portal_country();
                        _country.country_name = data.country;
                        _context.portal_country.Add(_country);
                        _context.SaveChanges();
                        country_id = _country.pk_country_id;
                    }
                    if (state_id == 0)
                    {
                        portal_state _state = new portal_state();
                        _state.state_name    = data.state;
                        _state.fk_country_id = country_id;
                        _context.portal_state.Add(_state);
                        _context.SaveChanges();
                        state_id = _state.pk_state_id;
                    }
                    if (city_id == 0)
                    {
                        portal_city _city = new portal_city();
                        _city.city_name   = data.city;
                        _city.fk_state_id = state_id;
                        _context.portal_city.Add(_city);
                        _context.SaveChanges();
                        city_id = _city.pk_city_id;
                    }
                    if (vendor_id == 0)
                    {
                        UserViewModel _user   = new UserViewModel();
                        IUserBL       _userbl = new UserEngine();
                        _user.user_name     = data.vendor_user_name;
                        _user.password      = data.vendor_password;
                        _user.firstname     = data.vendor_name;
                        _user.fk_country_id = country_id;
                        _user.fk_state_id   = state_id;
                        _user.fk_city_id    = city_id;
                        _user.fk_user_type  = 2;
                        vendorResponseOut   = _userbl.AddUserProfile(_user);
                    }
                    else
                    {
                        vendorResponseOut.trnId = vendor_id;
                    }
                    if (string.IsNullOrEmpty(technology_id))
                    {
                        portal_experise _expertise = new portal_experise();
                        _expertise.expertise_name = data.candidate_technology;
                        _context.portal_experise.Add(_expertise);
                        _context.SaveChanges();
                        technology_id = _expertise.pk_expertise_id.ToString();
                    }
                    //Recruiter name have to change Candidate
                    IRecruiterBL       _candidatebl = new RecruiterEngine();
                    RecruiterViewModel _candidate   = new RecruiterViewModel();
                    _candidate.firstname            = data.candidate_firstname;
                    _candidate.expertise_profession = technology_id;
                    _candidate.about_us             = data.candidate_one_liner_headline;
                    _candidate.fk_experience_level  = experience_level_id;
                    _candidate.fk_country_id        = country_id;
                    _candidate.fk_state_id          = state_id;
                    _candidate.fk_city_id           = city_id;
                    _candidate.availability         = data.availability;
                    _candidatebl.AddUpdateRecruiter(_candidate, vendorResponseOut.trnId);
                    parentResponseOut.status = ActionStatus.Success;
                    parentResponseOut.status = ActionMessage.RecordSaved;
                }

                catch (Exception ex)
                {
                    parentResponseOut.status  = ActionStatus.Fail;
                    parentResponseOut.message = ActionMessage.ApplicationException;
                }

                return(parentResponseOut);
            }
        }