Exemplo n.º 1
0
        public HttpResponseMessage Save(TranslateInterpretExperienceModel aTranslateInterpretExperienceModel)
        {
            IUnitOfWork uWork = new UnitOfWork();
            ITranslateInterpretExperienceRepository translateInterpretExperience        = new TranslateInterpretExperienceRepository(uWork);
            ITranslateInterpretExperienceService    translateInterpretExperienceService = new TranslateInterpretExperienceService(translateInterpretExperience);

            try
            {
                if (this.ModelState.IsValid)
                {
                    var TranslateInterpretExperienceModelList = translateInterpretExperienceService.SaveTranslateInterpretExperience(aTranslateInterpretExperienceModel);
                    if (TranslateInterpretExperienceModelList != null)
                    {
                        return(Request.CreateResponse(HttpStatusCode.OK, TranslateInterpretExperienceModelList));
                    }
                    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));
            }
        }
Exemplo n.º 2
0
        public HttpResponseMessage DeleteTranslateInterpretExperience(TranslateInterpretExperienceModel model)
        {
            IUnitOfWork uWork = new UnitOfWork();
            ITranslateInterpretExperienceRepository translateInterpretExperience        = new TranslateInterpretExperienceRepository(uWork);
            ITranslateInterpretExperienceService    translateInterpretExperienceService = new TranslateInterpretExperienceService(translateInterpretExperience);

            try
            {
                if (this.ModelState.IsValid)
                {
                    var result = translateInterpretExperienceService.DeleteTranslateInterpretExperience(model);
                    if (result != null)
                    {
                        return(Request.CreateResponse(HttpStatusCode.OK, result));
                    }
                    else
                    {
                        string message = "Not deleted successfully";
                        return(Request.CreateErrorResponse(HttpStatusCode.Forbidden, message));
                    }
                }
                else
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
                }
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex));
            }
        }
Exemplo n.º 3
0
        public bool SaveStaffTRExperience(TranslateInterpretExperienceModel staffTRExperienceModel)
        {
            var isSuccessful = true;
            Staff_TranslateInterpretExperience staffTRExperience = null;

            try
            {
                if (staffTRExperienceModel != null)
                {
                    staffTRExperience = Mapper.Map <TranslateInterpretExperienceModel, Staff_TranslateInterpretExperience>(staffTRExperienceModel);
                    if (staffTRExperience.ID == Guid.Empty)
                    {
                        staffTRExperience.ID          = Guid.NewGuid();
                        staffTRExperience.CreatedBy   = staffTRExperienceModel.CurrentUserID;
                        staffTRExperience.CreatedDate = DateTime.Now;
                        _dbContext.Staff_TranslateInterpretExperience.Add(staffTRExperience);
                    }
                    else
                    {
                        staffTRExperience.UpdatedBy   = staffTRExperienceModel.CurrentUserID;
                        staffTRExperience.UpdatedDate = DateTime.Now;
                        _dbContext.Entry(staffTRExperienceModel).State = EntityState.Modified;
                    }
                }
                _dbContext.SaveChanges();
            }
            catch (Exception ex)
            {
                isSuccessful = false;
                IErrorLogService errorLog = new ErrorLogService();
                string           message  = ex.InnerException != null ? ex.InnerException.InnerException.Message : ex.Message;
                errorLog.SetErrorLog(staffTRExperience.UpdatedBy.Value, "staffTRExperience", message);
                throw new Exception(message);
            }
            return(isSuccessful);
        }