예제 #1
0
        public virtual bool Create(ref ValidationErrors errors, MIS_WebIM_Message_RecModel model)
        {
            try
            {
                MIS_WebIM_Message_Rec entity = m_Rep.GetById(model.MessageId);
                if (entity != null)
                {
                    errors.Add(Resource.PrimaryRepeat);
                    return(false);
                }
                entity           = new MIS_WebIM_Message_Rec();
                entity.MessageId = model.MessageId;
                entity.receiver  = model.receiver;
                entity.State     = model.State;
                entity.RecDt     = model.RecDt;


                if (m_Rep.Create(entity))
                {
                    return(true);
                }
                else
                {
                    errors.Add(Resource.InsertFail);
                    return(false);
                }
            }
            catch (Exception ex)
            {
                errors.Add(ex.Message);
                ExceptionHander.WriteException(ex);
                return(false);
            }
        }
예제 #2
0
        public virtual bool Edit(ref ValidationErrors errors, MIS_WebIM_Message_RecModel model)
        {
            try
            {
                MIS_WebIM_Message_Rec entity = m_Rep.GetById(model.MessageId);
                if (entity == null)
                {
                    errors.Add(Resource.Disable);
                    return(false);
                }
                entity.MessageId = model.MessageId;
                entity.receiver  = model.receiver;
                entity.State     = model.State;
                entity.RecDt     = model.RecDt;



                if (m_Rep.Edit(entity))
                {
                    return(true);
                }
                else
                {
                    errors.Add(Resource.NoDataChange);
                    return(false);
                }
            }
            catch (Exception ex)
            {
                errors.Add(ex.Message);
                ExceptionHander.WriteException(ex);
                return(false);
            }
        }
예제 #3
0
        public virtual MIS_WebIM_Message_RecModel GetById(object id)
        {
            if (IsExists(id))
            {
                MIS_WebIM_Message_Rec      entity = m_Rep.GetById(id);
                MIS_WebIM_Message_RecModel model  = new MIS_WebIM_Message_RecModel();
                model.MessageId = entity.MessageId;
                model.receiver  = entity.receiver;
                model.State     = entity.State;
                model.RecDt     = entity.RecDt;

                return(model);
            }
            else
            {
                return(null);
            }
        }
        public virtual async Task <Tuple <ValidationErrors, bool> > CreateAsync(MIS_WebIM_Message_RecModel model)
        {
            ValidationErrors errors = new ValidationErrors();

            try
            {
                MIS_WebIM_Message_Rec entity = await m_Rep.GetByIdAsync(model.MessageId);

                if (entity != null)
                {
                    errors.Add(Resource.PrimaryRepeat);
                    return(new Tuple <ValidationErrors, bool>(errors, false));
                }
                entity           = new MIS_WebIM_Message_Rec();
                entity.MessageId = model.MessageId;
                entity.receiver  = model.receiver;
                entity.State     = model.State;
                entity.RecDt     = model.RecDt;


                if (await m_Rep.CreateAsync(entity))
                {
                    return(new Tuple <ValidationErrors, bool>(errors, true));
                }
                else
                {
                    errors.Add(Resource.InsertFail);
                    return(new Tuple <ValidationErrors, bool>(errors, false));
                }
            }
            catch (Exception ex)
            {
                errors.Add(ex.Message);
                ExceptionHander.WriteException(ex);
                return(new Tuple <ValidationErrors, bool>(errors, false));
            }
        }
예제 #5
0
        /// <summary>
        /// 保存数据
        /// </summary>
        public virtual void SaveImportData(IEnumerable <MIS_WebIM_Message_RecModel> list)
        {
            try
            {
                using (DBContainer db = new DBContainer())
                {
                    foreach (var model in list)
                    {
                        MIS_WebIM_Message_Rec entity = new MIS_WebIM_Message_Rec();
                        entity.MessageId = model.MessageId;
                        entity.receiver  = model.receiver;
                        entity.State     = model.State;
                        entity.RecDt     = model.RecDt;

                        db.MIS_WebIM_Message_Rec.Add(entity);
                    }
                    db.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }
        public virtual async Task <Tuple <ValidationErrors, bool> > EditAsync(MIS_WebIM_Message_RecModel model)
        {
            ValidationErrors errors = new ValidationErrors();

            try
            {
                MIS_WebIM_Message_Rec entity = await m_Rep.GetByIdAsync(model.MessageId);

                if (entity == null)
                {
                    errors.Add(Resource.Disable);
                    return(new Tuple <ValidationErrors, bool>(errors, false));
                }
                entity.MessageId = model.MessageId;
                entity.receiver  = model.receiver;
                entity.State     = model.State;
                entity.RecDt     = model.RecDt;


                if (await m_Rep.EditAsync(entity))
                {
                    return(new Tuple <ValidationErrors, bool>(errors, true));
                }
                else
                {
                    errors.Add(Resource.NoDataChange);
                    return(new Tuple <ValidationErrors, bool>(errors, false));
                }
            }
            catch (Exception ex)
            {
                errors.Add(ex.Message);
                ExceptionHander.WriteException(ex);
                return(new Tuple <ValidationErrors, bool>(errors, false));
            }
        }