public async Task <VerifyRecordResult> UpdateAsync(MyUserAdapterModel paraObject)
        {
            try
            {
                MyUser itemData = Mapper.Map <MyUser>(paraObject);
                CleanTrackingHelper.Clean <MyUser>(context);
                MyUser item = await context.MyUser
                              .AsNoTracking()
                              .FirstOrDefaultAsync(x => x.Id == paraObject.Id);

                if (item == null)
                {
                    return(VerifyRecordResultFactory.Build(false, ErrorMessageEnum.無法修改紀錄));
                }
                else
                {
                    CleanTrackingHelper.Clean <MyUser>(context);
                    context.Entry(itemData).State = EntityState.Modified;
                    await context.SaveChangesAsync();

                    CleanTrackingHelper.Clean <MyUser>(context);
                    return(VerifyRecordResultFactory.Build(true));
                }
            }
            catch (Exception ex)
            {
                Logger.LogError(ex, "修改記錄發生例外異常");
                return(VerifyRecordResultFactory.Build(false, "修改記錄發生例外異常", ex));
            }
        }
        public async Task <VerifyRecordResult> UpdateAsync(WorkingLogDetailAdapterModel paraObject)
        {
            WorkingLogDetail itemData = Mapper.Map <WorkingLogDetail>(paraObject);

            CleanTrackingHelper.Clean <WorkingLogDetail>(context);
            WorkingLogDetail item = await context.WorkingLogDetail
                                    .AsNoTracking()
                                    .FirstOrDefaultAsync(x => x.Id == paraObject.Id);

            if (item == null)
            {
                return(VerifyRecordResultFactory.Build(false, ErrorMessageEnum.無法修改紀錄));
            }
            else
            {
                CleanTrackingHelper.Clean <WorkingLogDetail>(context);
                context.Entry(itemData).State = EntityState.Modified;
                await context.SaveChangesAsync();

                var id = itemData.WorkingLogId;
                CleanTrackingHelper.Clean <WorkingLogDetail>(context);
                await CountingWorkingHour(id);

                return(VerifyRecordResultFactory.Build(true));
            }
        }
        public async Task <VerifyRecordResult> BeforeAddCheckAsync(MyUserAdapterModel paraObject)
        {
            if (paraObject.Account.ToLower() == MagicHelper.開發者帳號)
            {
                return(VerifyRecordResultFactory.Build(false, ErrorMessageEnum.開發者帳號不可以被新增));
            }

            var searchItem = await context.MyUser
                             .AsNoTracking()
                             .FirstOrDefaultAsync(x => x.Account == paraObject.Account);

            if (searchItem != null)
            {
                return(VerifyRecordResultFactory.Build(false, ErrorMessageEnum.要新增的紀錄已經存在無法新增));
            }
            var searchMenuRoleItem = await context.MenuRole
                                     .AsNoTracking()
                                     .FirstOrDefaultAsync(x => x.Id == paraObject.MenuRoleId);

            if (searchMenuRoleItem == null)
            {
                return(VerifyRecordResultFactory.Build(false, ErrorMessageEnum.沒有指定功能表角色項目));
            }

            return(VerifyRecordResultFactory.Build(true));
        }
        public async Task <VerifyRecordResult> BeforeDeleteCheckAsync(OrderMasterAdapterModel paraObject)
        {
            try
            {
                CleanTrackingHelper.Clean <OrderItem>(context);
                CleanTrackingHelper.Clean <OrderMaster>(context);

                var searchItem = await context.OrderMaster
                                 .AsNoTracking()
                                 .FirstOrDefaultAsync(x => x.Id == paraObject.Id);

                if (searchItem == null)
                {
                    return(VerifyRecordResultFactory.Build(false, ErrorMessageEnum.無法刪除紀錄_要刪除的紀錄已經不存在資料庫上));
                }

                var searchOrderItemItem = await context.OrderItem
                                          .AsNoTracking()
                                          .FirstOrDefaultAsync(x => x.OrderMasterId == paraObject.Id);

                if (searchOrderItemItem != null)
                {
                    return(VerifyRecordResultFactory.Build(false, ErrorMessageEnum.該紀錄無法刪除因為有其他資料表在使用中));
                }
                return(VerifyRecordResultFactory.Build(true));
            }
            catch (Exception ex)
            {
                return(VerifyRecordResultFactory.Build(false, "刪除記錄發生例外異常", ex));
            }
        }
Ejemplo n.º 5
0
        public async Task <VerifyRecordResult> BeforeUpdateCheckAsync(OrderItemAdapterModel paraObject)
        {
            CleanTrackingHelper.Clean <OrderItem>(context);
            if (paraObject.ProductId == 0)
            {
                return(VerifyRecordResultFactory.Build(false, ErrorMessageEnum.尚未輸入該訂單要用到的產品));
            }

            var searchItem = await context.OrderItem
                             .AsNoTracking()
                             .FirstOrDefaultAsync(x => x.Id == paraObject.Id);

            if (searchItem == null)
            {
                return(VerifyRecordResultFactory.Build(false, ErrorMessageEnum.要更新的紀錄_發生同時存取衝突_已經不存在資料庫上));
            }

            searchItem = await context.OrderItem
                         .AsNoTracking()
                         .FirstOrDefaultAsync(x => x.OrderMasterId == paraObject.OrderMasterId &&
                                              x.ProductId == paraObject.ProductId &&
                                              x.Id != paraObject.Id);

            if (searchItem != null)
            {
                return(VerifyRecordResultFactory.Build(false, ErrorMessageEnum.該訂單已經存在該產品_不能重複同樣的商品在一訂單內));
            }
            return(VerifyRecordResultFactory.Build(true));
        }
        public async Task <VerifyRecordResult> BeforeDeleteCheckAsync(MyUserAdapterModel paraObject)
        {
            if (paraObject.Account.ToLower() == MagicHelper.開發者帳號)
            {
                return(VerifyRecordResultFactory.Build(false, ErrorMessageEnum.開發者帳號不可以被刪除));
            }

            CleanTrackingHelper.Clean <MyUser>(context);
            var searchItem = await context.MyUser
                             .AsNoTracking()
                             .FirstOrDefaultAsync(x => x.Id == paraObject.Id);

            if (searchItem == null)
            {
                return(VerifyRecordResultFactory.Build(false, ErrorMessageEnum.無法刪除紀錄_要刪除的紀錄已經不存在資料庫上));
            }

            searchItem = await context.MyUser
                         .AsNoTracking()
                         .FirstOrDefaultAsync(x => x.Id == paraObject.Id);

            if (searchItem != null)
            {
                if (searchItem.Account.ToLower() == MagicHelper.開發者帳號)
                {
                    return(VerifyRecordResultFactory.Build(false, ErrorMessageEnum.開發者帳號不可以被刪除));
                }
            }
            else
            {
                return(VerifyRecordResultFactory.Build(false, ErrorMessageEnum.無法刪除紀錄_要刪除的紀錄已經不存在資料庫上));
            }
            return(VerifyRecordResultFactory.Build(true));
        }
        public async Task <VerifyRecordResult> BeforeUpdateCheckAsync(MenuDataAdapterModel paraObject)
        {
            CleanTrackingHelper.Clean <MenuData>(context);
            var searchItem = await context.MenuData
                             .AsNoTracking()
                             .FirstOrDefaultAsync(x => x.Id == paraObject.Id);

            if (searchItem == null)
            {
                return(VerifyRecordResultFactory.Build(false, ErrorMessageEnum.要更新的紀錄_發生同時存取衝突_已經不存在資料庫上));
            }

            if (paraObject.MenuRoleId == 0)
            {
                return(VerifyRecordResultFactory.Build(false, ErrorMessageEnum.尚未輸入功能表的角色));
            }
            var item = await context.MenuData
                       .AsNoTracking()
                       .FirstOrDefaultAsync(x => x.MenuRoleId == paraObject.MenuRoleId &&
                                            x.Name == paraObject.Name &&
                                            x.Id != paraObject.Id);

            if (item != null)
            {
                return(VerifyRecordResultFactory.Build(false, ErrorMessageEnum.該功能項目已經存在該功能表的角色));
            }
            return(VerifyRecordResultFactory.Build(true));
        }
        public async Task <VerifyRecordResult> DeleteAsync(int id)
        {
            try
            {
                CleanTrackingHelper.Clean <MyUser>(context);
                MyUser item = await context.MyUser
                              .AsNoTracking()
                              .FirstOrDefaultAsync(x => x.Id == id);

                if (item == null)
                {
                    return(VerifyRecordResultFactory.Build(false, ErrorMessageEnum.無法刪除紀錄));
                }
                else
                {
                    CleanTrackingHelper.Clean <MyUser>(context);
                    context.Entry(item).State = EntityState.Deleted;
                    await context.SaveChangesAsync();

                    CleanTrackingHelper.Clean <MyUser>(context);
                    return(VerifyRecordResultFactory.Build(true));
                }
            }
            catch (Exception ex)
            {
                Logger.LogError(ex, "刪除記錄發生例外異常");
                return(VerifyRecordResultFactory.Build(false, "刪除記錄發生例外異常", ex));
            }
        }
Ejemplo n.º 9
0
        public async Task <VerifyRecordResult> BeforeUpdateCheckAsync(PolicyDetailAdapterModel paraObject)
        {
            CleanTrackingHelper.Clean <PolicyDetail>(context);
            if (paraObject.MyUserId == 0)
            {
                return(VerifyRecordResultFactory.Build(false, "需要指定一個使用者"));
            }

            var searchItem = await context.PolicyDetail
                             .AsNoTracking()
                             .FirstOrDefaultAsync(x => x.Id == paraObject.Id);

            if (searchItem == null)
            {
                return(VerifyRecordResultFactory.Build(false, ErrorMessageEnum.要更新的紀錄_發生同時存取衝突_已經不存在資料庫上));
            }

            searchItem = await context.PolicyDetail
                         .AsNoTracking()
                         .FirstOrDefaultAsync(x => x.PolicyHeaderId == paraObject.PolicyHeaderId &&
                                              x.MyUserId == paraObject.MyUserId &&
                                              x.Id != paraObject.Id);

            if (searchItem != null)
            {
                return(VerifyRecordResultFactory.Build(false, "同一個簽核政策內,使用者不能重複指定"));
            }
            return(VerifyRecordResultFactory.Build(true));
        }
        public async Task <VerifyRecordResult> DeleteAsync(int id)
        {
            try
            {
                CleanTrackingHelper.Clean <FlowMaster>(context);
                FlowMaster item = await context.FlowMaster
                                  .AsNoTracking()
                                  .FirstOrDefaultAsync(x => x.Id == id);

                if (item == null)
                {
                    return(VerifyRecordResultFactory.Build(false, ErrorMessageEnum.無法刪除紀錄));
                }
                else
                {
                    #region 刪除其他關連紀錄
                    CleanTrackingHelper.Clean <FlowUser>(context);
                    CleanTrackingHelper.Clean <FlowHistory>(context);
                    CleanTrackingHelper.Clean <FlowInbox>(context);
                    var auditUsers = await context.FlowUser
                                     .Where(x => x.FlowMasterId == id)
                                     .ToListAsync();

                    context.FlowUser.RemoveRange(auditUsers);
                    var auditHistories = await context.FlowHistory
                                         .Where(x => x.FlowMasterId == id)
                                         .ToListAsync();

                    context.FlowHistory.RemoveRange(auditHistories);
                    var flowInbox = await context.FlowInbox
                                    .Where(x => x.FlowMasterId == id)
                                    .ToListAsync();

                    context.FlowInbox.RemoveRange(flowInbox);
                    await context.SaveChangesAsync();

                    #endregion

                    CleanTrackingHelper.Clean <FlowMaster>(context);
                    context.Entry(item).State = EntityState.Deleted;
                    await context.SaveChangesAsync();

                    CleanTrackingHelper.Clean <FlowInbox>(context);
                    CleanTrackingHelper.Clean <FlowMaster>(context);
                    CleanTrackingHelper.Clean <FlowHistory>(context);
                    return(VerifyRecordResultFactory.Build(true));
                }
            }
            catch (Exception ex)
            {
                Logger.LogError(ex, "刪除記錄發生例外異常");
                return(VerifyRecordResultFactory.Build(false, "刪除記錄發生例外異常", ex));
            }
        }
        public async Task <VerifyRecordResult> BeforeAddCheckAsync(PhaseMessageAdapterModel paraObject)
        {
            CleanTrackingHelper.Clean <PhaseMessage>(context);
            await Task.Yield();

            if (paraObject.PhaseCategoryId == 0)
            {
                return(VerifyRecordResultFactory.Build(false, "需要指定一個片語分類"));
            }
            return(VerifyRecordResultFactory.Build(true));
        }
        public async Task <VerifyRecordResult> BeforeUpdateCheckAsync(CategorySubAdapterModel paraObject)
        {
            var searchItem = await context.CategorySub
                             .AsNoTracking()
                             .FirstOrDefaultAsync(x => x.Id == paraObject.Id);

            if (searchItem == null)
            {
                return(VerifyRecordResultFactory.Build(false, ErrorMessageEnum.要更新的紀錄_發生同時存取衝突_已經不存在資料庫上));
            }
            return(VerifyRecordResultFactory.Build(true));
        }
Ejemplo n.º 13
0
        public async Task <VerifyRecordResult> BeforeAddCheckAsync(ProjectAdapterModel paraObject)
        {
            var searchItem = await context.Project
                             .AsNoTracking()
                             .FirstOrDefaultAsync(x => x.Name == paraObject.Name);

            if (searchItem != null)
            {
                return(VerifyRecordResultFactory.Build(false, ErrorMessageEnum.要新增的紀錄已經存在無法新增));
            }
            return(VerifyRecordResultFactory.Build(true));
        }
        public async Task <VerifyRecordResult> BeforeAddCheckAsync(TravelExpenseAdapterModel paraObject)
        {
            var searchMyUserItem = await context.MyUser
                                   .AsNoTracking()
                                   .FirstOrDefaultAsync(x => x.Id == paraObject.MyUserId);

            if (searchMyUserItem == null)
            {
                return(VerifyRecordResultFactory.Build(false, ErrorMessageEnum.需要指定使用者));
            }
            return(VerifyRecordResultFactory.Build(true));
        }
        public async Task <VerifyRecordResult> BeforeDeleteCheckAsync(MenuDataAdapterModel paraObject)
        {
            var searchItem = await context.MenuData
                             .AsNoTracking()
                             .FirstOrDefaultAsync(x => x.Id == paraObject.Id);

            if (searchItem == null)
            {
                return(VerifyRecordResultFactory.Build(false, ErrorMessageEnum.無法刪除紀錄_要刪除的紀錄已經不存在資料庫上));
            }
            return(VerifyRecordResultFactory.Build(true));
        }
        public async Task <VerifyRecordResult> BeforeDeleteCheckAsync(FlowMasterAdapterModel paraObject)
        {
            try
            {
                CleanTrackingHelper.Clean <FlowMaster>(context);
                CleanTrackingHelper.Clean <FlowInbox>(context);
                CleanTrackingHelper.Clean <FlowHistory>(context);
                CleanTrackingHelper.Clean <FlowUser>(context);

                var searchItem = await context.FlowMaster
                                 .AsNoTracking()
                                 .FirstOrDefaultAsync(x => x.Id == paraObject.Id);

                if (searchItem == null)
                {
                    return(VerifyRecordResultFactory.Build(false, "無法刪除紀錄,要刪除的紀錄已經不存在資料庫上"));
                }

                var searchFlowInboxItem = await context.FlowInbox
                                          .AsNoTracking()
                                          .FirstOrDefaultAsync(x => x.FlowMasterId == paraObject.Id);

                if (searchFlowInboxItem != null)
                {
                    return(VerifyRecordResultFactory.Build(false, "該筆紀錄還有 收件匣 資料表紀錄參考使用,無法刪除"));
                }

                var searchFlowHistoryItem = await context.FlowHistory
                                            .AsNoTracking()
                                            .FirstOrDefaultAsync(x => x.FlowMasterId == paraObject.Id);

                if (searchFlowHistoryItem != null)
                {
                    return(VerifyRecordResultFactory.Build(false, "該筆紀錄還有 簽核歷程 資料表紀錄參考使用,無法刪除"));
                }

                var searchFlowUserItem = await context.FlowUser
                                         .AsNoTracking()
                                         .FirstOrDefaultAsync(x => x.FlowMasterId == paraObject.Id);

                if (searchFlowUserItem != null)
                {
                    return(VerifyRecordResultFactory.Build(false, "該筆紀錄還有 參與簽核使用者 資料表紀錄參考使用,無法刪除"));
                }

                return(VerifyRecordResultFactory.Build(true));
            }
            catch (Exception ex)
            {
                return(VerifyRecordResultFactory.Build(false, "刪除記錄發生例外異常", ex));
            }
        }
        public async Task <VerifyRecordResult> AddAsync(TravelExpenseAdapterModel paraObject)
        {
            TravelExpense itemParameter = Mapper.Map <TravelExpense>(paraObject);

            CleanTrackingHelper.Clean <TravelExpense>(context);
            await context.TravelExpense
            .AddAsync(itemParameter);

            await context.SaveChangesAsync();

            CleanTrackingHelper.Clean <TravelExpense>(context);
            return(VerifyRecordResultFactory.Build(true));
        }
        public async Task <VerifyRecordResult> BeforeUpdateCheckAsync(MyUserAdapterModel paraObject)
        {
            var searchItem = await context.MyUser
                             .AsNoTracking()
                             .FirstOrDefaultAsync(x => x.Account == paraObject.Account &&
                                                  x.Id != paraObject.Id);

            if (searchItem != null)
            {
                return(VerifyRecordResultFactory.Build(false, ErrorMessageEnum.要修改的紀錄已經存在無法修改));
            }
            return(VerifyRecordResultFactory.Build(true));
        }
        public async Task <VerifyRecordResult> BeforeDeleteCheckAsync(LeaveCategoryAdapterModel paraObject)
        {
            CleanTrackingHelper.Clean <LeaveForm>(context);
            LeaveForm item = await context.LeaveForm
                             .AsNoTracking()
                             .FirstOrDefaultAsync(x => x.LeaveCategoryId == paraObject.Id);

            if (item != null)
            {
                return(VerifyRecordResultFactory.Build(false, ErrorMessageEnum.該紀錄無法刪除因為有其他資料表在使用中));
            }
            return(VerifyRecordResultFactory.Build(true));
        }
        public async Task <VerifyRecordResult> BeforeDeleteCheckAsync(SystemLogAdapterModel paraObject)
        {
            CleanTrackingHelper.Clean <OrderItem>(context);
            var searchItem = await context.SystemLog
                             .AsNoTracking()
                             .FirstOrDefaultAsync(x => x.Id == paraObject.Id);

            if (searchItem == null)
            {
                return(VerifyRecordResultFactory.Build(false, ErrorMessageEnum.無法刪除紀錄_要刪除的紀錄已經不存在資料庫上));
            }
            return(VerifyRecordResultFactory.Build(true));
        }
        public async Task <VerifyRecordResult> AddAsync(LeaveCategoryAdapterModel paraObject)
        {
            LeaveCategory itemParameter = Mapper.Map <LeaveCategory>(paraObject);

            CleanTrackingHelper.Clean <LeaveCategory>(context);
            await context.LeaveCategory
            .AddAsync(itemParameter);

            await context.SaveChangesAsync();

            CleanTrackingHelper.Clean <LeaveCategory>(context);
            return(VerifyRecordResultFactory.Build(true));
        }
Ejemplo n.º 22
0
        public async Task <VerifyRecordResult> BeforeDeleteCheckAsync(ProjectAdapterModel paraObject)
        {
            CleanTrackingHelper.Clean <WorkingLogDetail>(context);
            WorkingLogDetail item = await context.WorkingLogDetail
                                    .AsNoTracking()
                                    .FirstOrDefaultAsync(x => x.ProjectId == paraObject.Id);

            if (item != null)
            {
                return(VerifyRecordResultFactory.Build(false, ErrorMessageEnum.該紀錄無法刪除因為有其他資料表在使用中));
            }
            return(VerifyRecordResultFactory.Build(true));
        }
Ejemplo n.º 23
0
        public async Task <VerifyRecordResult> AddAsync(ProjectAdapterModel paraObject)
        {
            Project itemParameter = Mapper.Map <Project>(paraObject);

            CleanTrackingHelper.Clean <Project>(context);
            await context.Project
            .AddAsync(itemParameter);

            await context.SaveChangesAsync();

            CleanTrackingHelper.Clean <Project>(context);
            return(VerifyRecordResultFactory.Build(true));
        }
Ejemplo n.º 24
0
        public async Task <VerifyRecordResult> AddAsync(OrderMasterAdapterModel paraObject)
        {
            CleanTrackingHelper.Clean <OrderMaster>(context);
            OrderMaster itemParameter = Mapper.Map <OrderMaster>(paraObject);

            CleanTrackingHelper.Clean <OrderMaster>(context);
            await context.OrderMaster
            .AddAsync(itemParameter);

            await context.SaveChangesAsync();

            CleanTrackingHelper.Clean <OrderMaster>(context);
            return(VerifyRecordResultFactory.Build(true));
        }
        public async Task <VerifyRecordResult> BeforeAddCheckAsync(WorkOrderAdapterModel paraObject)
        {
            await Task.Yield();

            if (paraObject.CategoryMainId == 0)
            {
                return(VerifyRecordResultFactory.Build(false, "請選擇派工單主分類"));
            }
            if (paraObject.CategorySubId == 0)
            {
                return(VerifyRecordResultFactory.Build(false, "請選擇派工單次分類"));
            }
            return(VerifyRecordResultFactory.Build(true));
        }
Ejemplo n.º 26
0
        public async Task <VerifyRecordResult> BeforeAddCheckAsync(FlowInboxAdapterModel paraObject)
        {
            await Task.Yield();

            if (paraObject.MyUserId == 0)
            {
                return(VerifyRecordResultFactory.Build(false, "需要指定一個使用者"));
            }
            if (paraObject.FlowMasterId == 0)
            {
                return(VerifyRecordResultFactory.Build(false, "需要指定一個簽核申請"));
            }

            return(VerifyRecordResultFactory.Build(true));
        }
        public async Task <VerifyRecordResult> AddAsync(WorkingLogDetailAdapterModel paraObject)
        {
            WorkingLogDetail itemParameter = Mapper.Map <WorkingLogDetail>(paraObject);

            CleanTrackingHelper.Clean <WorkingLogDetail>(context);
            await context.WorkingLogDetail
            .AddAsync(itemParameter);

            await context.SaveChangesAsync();

            var id = itemParameter.WorkingLogId;

            CleanTrackingHelper.Clean <WorkingLogDetail>(context);
            await CountingWorkingHour(id);

            return(VerifyRecordResultFactory.Build(true));
        }
        public async Task <VerifyRecordResult> BeforeUpdateCheckAsync(MyUserAdapterModel paraObject)
        {
            //if (paraObject.Account.ToLower() == MagicHelper.開發者帳號)
            //{
            //    return VerifyRecordResultFactory.Build(false, ErrorMessageEnum.開發者帳號不可以被修改);
            //}

            CleanTrackingHelper.Clean <MyUser>(context);
            var searchItem = await context.MyUser
                             .AsNoTracking()
                             .FirstOrDefaultAsync(x => x.Id == paraObject.Id);

            if (searchItem == null)
            {
                return(VerifyRecordResultFactory.Build(false, ErrorMessageEnum.要更新的紀錄_發生同時存取衝突_已經不存在資料庫上));
            }

            searchItem = await context.MyUser
                         .AsNoTracking()
                         .FirstOrDefaultAsync(x => x.Id == paraObject.Id);

            if (searchItem != null)
            {
                //if (searchItem.Account.ToLower() == MagicHelper.開發者帳號)
                //{
                //    return VerifyRecordResultFactory.Build(false, ErrorMessageEnum.開發者帳號不可以被修改);
                //}
            }
            else
            {
                return(VerifyRecordResultFactory.Build(false, ErrorMessageEnum.要更新的紀錄_發生同時存取衝突_已經不存在資料庫上));
            }

            searchItem = await context.MyUser
                         .AsNoTracking()
                         .FirstOrDefaultAsync(x => x.Account == paraObject.Account &&
                                              x.Id != paraObject.Id);

            if (searchItem != null)
            {
                return(VerifyRecordResultFactory.Build(false, ErrorMessageEnum.要修改的紀錄已經存在無法修改));
            }

            return(VerifyRecordResultFactory.Build(true));
        }
Ejemplo n.º 29
0
        public async Task <VerifyRecordResult> BeforeAddCheckAsync(PolicyDetailAdapterModel paraObject)
        {
            CleanTrackingHelper.Clean <PolicyDetail>(context);
            if (paraObject.MyUserId == 0)
            {
                return(VerifyRecordResultFactory.Build(false, "需要指定一個使用者"));
            }
            var item = await context.PolicyDetail
                       .AsNoTracking()
                       .FirstOrDefaultAsync(x => x.PolicyHeaderId == paraObject.PolicyHeaderId &&
                                            x.MyUserId == paraObject.MyUserId);

            if (item != null)
            {
                return(VerifyRecordResultFactory.Build(false, "同一個簽核政策內,使用者不能重複指定"));
            }
            return(VerifyRecordResultFactory.Build(true));
        }
Ejemplo n.º 30
0
        public async Task <VerifyRecordResult> AddAsync(ExceptionRecordAdapterModel paraObject)
        {
            ExceptionRecord itemParameter = Mapper.Map <ExceptionRecord>(paraObject);

            CleanTrackingHelper.Clean <ExceptionRecord>(context);
            try
            {
                await context.ExceptionRecord
                .AddAsync(itemParameter);

                await context.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            CleanTrackingHelper.Clean <ExceptionRecord>(context);
            return(VerifyRecordResultFactory.Build(true));
        }