Esempio n. 1
0
        //==========================BeforSave==========================

        public static List <TR01C> BeforSave(List <TR01CModel> data, EditType editType)
        {
            List <TR01C> list = new List <TR01C>();

            if (editType == EditType.AddNew)
            {
                foreach (var item in data)
                {
                    item.CREATE_USER = UserInfo.Id;
                    item.CREATE_DATE = DateTime.Now;
                    list.Add(ToEntity(item));
                }
            }
            else
            {
                TR01Service _Service    = new TR01Service();
                var         DBTR01CList = _Service.GetC(data.Select(x => x.TR01C_ID).ToList());
                foreach (var item in DBTR01CList)
                {
                    var tempData = data.First(x => x.TR01C_ID == item.TR01C_ID);
                    tempData.TR01A_ID    = item.TR01A_ID;
                    tempData.CREATE_USER = item.CREATE_USER;
                    tempData.CREATE_DATE = item.CREATE_DATE;
                    tempData.UPDATE_USER = UserInfo.Id;
                    tempData.UPDATE_DATE = DateTime.Now;
                    list.Add(ToEntity(tempData));
                }
            }
            return(list);
        }
Esempio n. 2
0
        public static TR01C BeforSave(TR01CModel data)
        {
            var TR01C = new TR01C();

            if (data.TR01C_ID == 0)//Adding New
            {
                data.CREATE_USER = UserInfo.Id;
                data.CREATE_DATE = DateTime.Now;
            }
            else//Update
            {
                var _Service = new TR01Service();
                TR01C            = _Service.GetC(x => x.TR01C_ID == data.TR01C_ID).First();
                data.CREATE_USER = TR01C.CREATE_USER;
                data.CREATE_DATE = TR01C.CREATE_DATE;
            }
            data.UPDATE_USER = UserInfo.Id;
            data.UPDATE_DATE = DateTime.Now;

            return(ToEntity(data));
        }