コード例 #1
0
        public HttpResponseMessage DeleteTransproInformation(TransproInformationModel model)
        {
            IUnitOfWork uWork = new UnitOfWork();
            ITransproInformationRepository transproInformation        = new TransproInformationRepository(uWork);
            ITransproInformationService    transproInformationService = new TransproInformationService(transproInformation);

            try
            {
                if (this.ModelState.IsValid)
                {
                    var result = transproInformationService.DeleteTransproInformation(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));
            }
        }
コード例 #2
0
        public HttpResponseMessage Save(TransproInformationModel aTransproInformationModel)
        {
            IUnitOfWork uWork = new UnitOfWork();
            ITransproInformationRepository transproInformation        = new TransproInformationRepository(uWork);
            ITransproInformationService    transproInformationService = new TransproInformationService(transproInformation);

            try
            {
                if (this.ModelState.IsValid)
                {
                    var TransproInformationList = transproInformationService.SaveTransproInformation(aTransproInformationModel);
                    if (TransproInformationList != null)
                    {
                        return(Request.CreateResponse(HttpStatusCode.OK, TransproInformationList));
                    }
                    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));
            }
        }
コード例 #3
0
ファイル: StaffService.cs プロジェクト: EnggJibon/HiworkERP
        public bool SaveTransPro(TransproInformationModel transproInformationModel)
        {
            var isSuccessful = true;
            Staff_TransproInformation staffTransproInformation = null;

            try
            {
                if (transproInformationModel != null)
                {
                    staffTransproInformation = Mapper.Map <TransproInformationModel, Staff_TransproInformation>(transproInformationModel);
                    if (staffTransproInformation.ID == Guid.Empty)
                    {
                        staffTransproInformation.ID          = Guid.NewGuid();
                        staffTransproInformation.CreatedBy   = transproInformationModel.CurrentUserID;
                        staffTransproInformation.CreatedDate = DateTime.Now;
                        _dbContext.Staff_TransproInformation.Add(staffTransproInformation);
                    }
                    else
                    {
                        staffTransproInformation.UpdatedBy               = transproInformationModel.CurrentUserID;
                        staffTransproInformation.UpdatedDate             = DateTime.Now;
                        _dbContext.Entry(staffTransproInformation).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(transproInformationModel.CreatedBy.Value, "staffTRExperience", message);
                throw new Exception(message);
            }
            return(isSuccessful);
        }