public async Task <int> SaveModuleAccessPage(ModuleAccessPage userAccessPage)
        {
            try
            {
                if (userAccessPage.Id != 0)
                {
                    userAccessPage.updatedBy = userAccessPage.createdBy;
                    userAccessPage.updatedAt = DateTime.Now;
                    _context.ModuleAccessPages.Update(userAccessPage);
                }
                else
                {
                    userAccessPage.createdAt = DateTime.Now;
                    _context.ModuleAccessPages.Add(userAccessPage);
                }

                await _context.SaveChangesAsync();

                return(userAccessPage.Id);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
 public async Task <bool> SaveCountry(Country country)
 {
     if (country.Id != 0)
     {
         _context.Countries.Update(country);
     }
     else
     {
         _context.Countries.Add(country);
     }
     return(1 == await _context.SaveChangesAsync());
 }
Пример #3
0
        public async Task <int> SaveAddressCategory(AddressCategory addressCategory)
        {
            if (addressCategory.Id != 0)
            {
                _context.AddressCategories.Update(addressCategory);

                await _context.SaveChangesAsync();

                return(1);
            }

            await _context.AddressCategories.AddAsync(addressCategory);

            await _context.SaveChangesAsync();

            return(1);
        }
        public async Task <int> SaveAttachmentType(AttachmentType attachmentType)
        {
            if (attachmentType.Id != 0)
            {
                _context.AttachmentTypes.Update(attachmentType);

                await _context.SaveChangesAsync();

                return(1);
            }

            await _context.AttachmentTypes.AddAsync(attachmentType);

            await _context.SaveChangesAsync();

            return(1);
        }
Пример #5
0
        public async Task <int> SaveAddressInformation(AddressInformation addressInformation)
        {
            if (addressInformation.Id != 0)
            {
                _context.AddressInformation.Update(addressInformation);

                await _context.SaveChangesAsync();

                return(1);
            }

            await _context.AddressInformation.AddAsync(addressInformation);

            await _context.SaveChangesAsync();

            return(1);
        }
        public async Task <int> SaveOtherDocumentDetail(OtherDocumentDetail otherDocumentDetail)
        {
            if (otherDocumentDetail.Id != 0)
            {
                _context.OtherDocumentDetails.Update(otherDocumentDetail);

                await _context.SaveChangesAsync();

                return(otherDocumentDetail.Id);
            }
            else
            {
                await _context.OtherDocumentDetails.AddAsync(otherDocumentDetail);

                await _context.SaveChangesAsync();

                return(otherDocumentDetail.Id);
            }
        }
        public async Task <bool> SaveMailLog(MailLog mailLog)
        {
            if (mailLog.Id != 0)
            {
                _context.MailLogs.Update(mailLog);
            }
            else
            {
                _context.MailLogs.Add(mailLog);
            }

            return(1 == await _context.SaveChangesAsync());
        }
 public async Task <bool> DeleteNavbarItemById(int id)
 {
     _context.Navbars.Remove(_context.Navbars.Find(id));
     return(1 == await _context.SaveChangesAsync());
 }
Пример #9
0
        public async Task <int> SaveAddressSourceType(AddressSourceType addressSourceType)
        {
            if (addressSourceType.Id != 0)
            {
                _context.AddressSourceTypes.Update(addressSourceType);

                await _context.SaveChangesAsync();

                return(1);
            }
            else
            {
                await _context.AddressSourceTypes.AddAsync(addressSourceType);

                await _context.SaveChangesAsync();

                return(1);
            }
        }
        public async Task <int> SaveLostAndFoundType(LostAndFoundType lostAndFoundType)
        {
            if (lostAndFoundType.Id != 0)
            {
                _context.LostAndFoundTypes.Update(lostAndFoundType);

                await _context.SaveChangesAsync();

                return(1);
            }
            else
            {
                await _context.LostAndFoundTypes.AddAsync(lostAndFoundType);

                await _context.SaveChangesAsync();

                return(1);
            }
        }
Пример #11
0
        public async Task <int> SaveElectronicsType(ElectronicsType electronicsType)
        {
            if (electronicsType.Id != 0)
            {
                _context.ElectronicsTypes.Update(electronicsType);

                await _context.SaveChangesAsync();

                return(1);
            }
            else
            {
                await _context.ElectronicsTypes.AddAsync(electronicsType);

                await _context.SaveChangesAsync();

                return(1);
            }
        }
Пример #12
0
        /// <summary>
        /// 增加一条记录
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public async Task InstertAsync(TEntity entity)
        {
            await Table.AddAsync(entity);

            await _dbContext.SaveChangesAsync();
        }
Пример #13
0
        public async Task <int> SaveGDInformation(GDInformation gDInformation)
        {
            if (gDInformation.Id != 0)
            {
                _context.GDInformation.Update(gDInformation);

                await _context.SaveChangesAsync();

                return(gDInformation.Id);
            }
            else
            {
                await _context.GDInformation.AddAsync(gDInformation);

                await _context.SaveChangesAsync();

                return(gDInformation.Id);
            }
        }