public HttpResponseMessage SaveStaffCurrentState(StaffCurrentStateModel amodel)
        {
            try
            {
                if (this.ModelState.IsValid)
                {
                    var staffstatelist = service.SaveStaffCurrentState(amodel);

                    if (staffstatelist != null)
                    {
                        return(Request.CreateResponse(HttpStatusCode.OK, staffstatelist));
                    }
                    else
                    {
                        string message = "Error Saving Data";
                        return(Request.CreateErrorResponse(HttpStatusCode.Forbidden, message));
                    }
                }
                else
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
                }
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.InnerException.Message));
            }
        }
Esempio n. 2
0
        public StaffModel GetTranslatorByID(BaseViewModel model)
        {
            StaffModel translator = new StaffModel();
            StaffBankAccountInfoModel              bankaccountInfo     = new StaffBankAccountInfoModel();
            List <StaffBankAccountInfoModel>       bankaccountInfoList = new List <StaffBankAccountInfoModel>();
            StaffSoftwareSkillModel                skillmodel          = new StaffSoftwareSkillModel();
            List <StaffSoftwareSkillModel>         skillList           = new List <StaffSoftwareSkillModel>();
            List <StaffProfesionalSpecialityModel> spModel             = new List <StaffProfesionalSpecialityModel>();
            StaffProfesionalSpecialityModel        sModel    = new StaffProfesionalSpecialityModel();
            List <StaffCurrentStateModel>          statelist = new List <StaffCurrentStateModel>();
            StaffCurrentStateModel usModel = new StaffCurrentStateModel();

            try
            {
                var trans = _StaffRepository.GetById(model.ID);
                translator           = Mapper.Map <Staff, StaffModel>(trans);
                translator.Staffbank = Mapper.Map <Staff_BankAccountInfo, StaffBankAccountInfoModel>(trans.Staff_BankAccountInfo.FirstOrDefault());


                if (trans != null)
                {
                    translator.ApartmentName = Utility.GetPropertyValue(trans, "ApartmentName", model.CurrentCulture) == null ? string.Empty :
                                               Utility.GetPropertyValue(trans, "ApartmentName", model.CurrentCulture).ToString();

                    translator.FirstName = Utility.GetPropertyValue(trans, "FirstName", model.CurrentCulture) == null ? string.Empty :
                                           Utility.GetPropertyValue(trans, "FirstName", model.CurrentCulture).ToString();

                    translator.LastName = Utility.GetPropertyValue(trans, "LastName", model.CurrentCulture) == null ? string.Empty :
                                          Utility.GetPropertyValue(trans, "LastName", model.CurrentCulture).ToString();

                    translator.Street = Utility.GetPropertyValue(trans, "Street", model.CurrentCulture) == null ? string.Empty :
                                        Utility.GetPropertyValue(trans, "Street", model.CurrentCulture).ToString();

                    translator.MainCareer = Utility.GetPropertyValue(trans, "MainCareer", model.CurrentCulture) == null ? string.Empty :
                                            Utility.GetPropertyValue(trans, "MainCareer", model.CurrentCulture).ToString();

                    translator.SelfPR = Utility.GetPropertyValue(trans, "SelfPR", model.CurrentCulture) == null ? string.Empty :
                                        Utility.GetPropertyValue(trans, "SelfPR", model.CurrentCulture).ToString();

                    translator.CityOfOverseas = Utility.GetPropertyValue(trans, "CityOfOverseas", model.CurrentCulture) == null ? string.Empty :
                                                Utility.GetPropertyValue(trans, "CityOfOverseas", model.CurrentCulture).ToString();

                    translator.CountryOfCitizenshipName = Utility.GetPropertyValue(trans.Master_Country, "Name", model.CurrentCulture) == null ? string.Empty :
                                                          Utility.GetPropertyValue(trans.Master_Country, "Name", model.CurrentCulture).ToString();

                    translator.Image = trans.Image;
                    translator.Staffbank.AccountHolderName = Utility.GetPropertyValue(trans.Staff_BankAccountInfo.FirstOrDefault(), "AccountHolderName", model.CurrentCulture) == null ? string.Empty :
                                                             Utility.GetPropertyValue(trans.Staff_BankAccountInfo.FirstOrDefault(), "AccountHolderName", model.CurrentCulture).ToString();


                    var StaffSoftwareSkillList = trans.Staff_SoftwareSkill.ToList();
                    translator.staffsoft = skillList;

                    if (StaffSoftwareSkillList.Count() > 0)
                    {
                        StaffSoftwareSkillList.ForEach(a =>
                        {
                            //if (a.StaffID == trans.ID)
                            //{
                            skillmodel = Mapper.Map <Staff_SoftwareSkill, StaffSoftwareSkillModel>(a);
                            skillmodel.CurrentUserID  = model.CurrentUserID;
                            skillmodel.CurrentCulture = model.CurrentCulture;
                            skillList.Add(skillmodel);
                            //}
                        });
                    }

                    var StaffProfessionalSpecialityList = trans.Staff_ProfessionalSpeciality.ToList();
                    translator.StaffProfessional = spModel;
                    if (StaffProfessionalSpecialityList.Count() > 0)
                    {
                        StaffProfessionalSpecialityList.ForEach(a =>
                        {
                            sModel = Mapper.Map <Staff_ProfessionalSpeciality, StaffProfesionalSpecialityModel>(a);
                            sModel.CurrentUserID  = model.CurrentUserID;
                            sModel.CurrentCulture = model.CurrentCulture;
                            spModel.Add(sModel);
                        });
                    }

                    var StaffCurrentStateList = trans.Staff_CurrentStates.ToList();
                    translator.StaffCurrentState = statelist;
                    if (StaffCurrentStateList.Count() > 0)
                    {
                        StaffCurrentStateList.ForEach(a =>
                        {
                            usModel = Mapper.Map <Staff_CurrentStates, StaffCurrentStateModel>(a);
                            usModel.CurrentUserID  = model.CurrentUserID;
                            usModel.CurrentCulture = model.CurrentCulture;
                            statelist.Add(usModel);
                        });
                    }
                }
            }

            catch (Exception ex)
            {
                IErrorLogService errorLog = new ErrorLogService();
                string           message  = ex.InnerException != null ? ex.InnerException.InnerException.Message : ex.Message;
                // errorLog.SetErrorLog(model.CurrentUserID, "Translator By ID", message);
                throw new Exception(message);
            }

            return(translator);
        }