コード例 #1
0
        public T GetByKey(Guid id)
        {
            if (DevMode.IsDevMode)
            {
                var entity = _globalRepository.GetByKey(id);
                if (entity != null)
                {
                    entity.SetDataLevel(DataLevel.Global);
                }
                return(entity);
            }
            T result = _globalRepository.GetByKey(id);

            if (result == null)
            {
                result = _profileRepository.GetByKey(id);
                if (result != null)
                {
                    result.SetDataLevel(DataLevel.Profile);
                }
            }
            else
            {
                result.SetDataLevel(DataLevel.Global);
            }
            return(result);
        }
コード例 #2
0
        public string GetMeasureSite(int id)
        {
            string                 result   = string.Empty;
            List <MonitorTree>     monitors = monitorTreeRepository.GetDatas <MonitorTree>(t => true, true).ToList();
            List <MonitorTreeType> mtTypes  = monitorTreeTypeRepository.GetDatas <MonitorTreeType>(t => true, true).ToList();

            MeasureSite msite = measureSiteRepository.GetByKey(id);

            if (msite != null)
            {
                int    serialNo = 0;
                string msName   = string.Empty;
                var    msType   = measureSiteTypeRepository.GetByKey(msite.MSiteName);
                if (msType != null)
                {
                    msName = msType.Name;
                    Int32.TryParse(msType.Describe, out serialNo);
                }

                var device = deviceRepository.GetByKey(msite.DevID);
                if (device != null)
                {
                    result = Json.Stringify(getdata.GetMeasuresite(msite, monitors, device, msName, serialNo, mtTypes));
                }
            }

            return(result);
        }
コード例 #3
0
        private Negotiator GetNoteByIDResponse(dynamic parameters)
        {
            Guid id   = parameters.id;
            var  note = _noteRepository.GetByKey(id);

            return(Negotiate
                   .WithStatusCode(HttpStatusCode.OK)
                   .WithModel(note));
        }
コード例 #4
0
        public async Task <long> UpdateProductAsync(long id, string name, string description, string barcode, decimal price, int stock, List <string> imageUrls)
        {
            var product = _productRepository.GetByKey(id);
            var images  = imageUrls.Select(x => new ProductImage(x)).ToList();

            product.Update(name, description, barcode, price, stock, images);
            await _productRepository.ModifyAndSaveAsync(product);

            return(product.Id);
        }
コード例 #5
0
        public string GetVibSignal(int id)
        {
            var signal = vibSignalRepository.GetByKey(id);

            if (signal != null)
            {
                return(Json.Stringify(GetCloudSignal(signal)));
            }

            return(string.Empty);
        }
コード例 #6
0
        private void GetVibSignalPara(VibSingal signal)
        {
            int value = -1;

            if (signal.LowLimitFrequency.HasValue)
            {
                var lowLimitType = waveLowerLimitValueRepository.GetByKey(signal.LowLimitFrequency.Value);
                if (lowLimitType != null)
                {
                    value = lowLimitType.WaveLowerLimitValue;
                }
                signal.LowLimitFrequency = value;
            }

            if (signal.UpLimitFrequency.HasValue)
            {
                var upperLimitType = waveUpperLimitValueRepository.GetByKey(signal.UpLimitFrequency.Value);
                if (upperLimitType != null)
                {
                    value = upperLimitType.WaveUpperLimitValue;
                }
                signal.UpLimitFrequency = value;
            }

            if (signal.EnlvpBandW.HasValue)
            {
                var enlvBandType = waveUpperLimitValueRepository.GetByKey(signal.EnlvpBandW.Value);
                if (enlvBandType != null)
                {
                    value = enlvBandType.WaveUpperLimitValue;
                }
                signal.EnlvpBandW = value;
            }

            if (signal.EnlvpFilter.HasValue)
            {
                var envlFilterType = waveLowerLimitValueRepository.GetByKey(signal.EnlvpFilter.Value);
                if (envlFilterType != null)
                {
                    value = envlFilterType.WaveLowerLimitValue;
                }
                signal.EnlvpFilter = value;
            }

            var waveLenType = waveLengthValueRepository.GetByKey(signal.WaveDataLength);

            if (waveLenType != null)
            {
                value = waveLenType.WaveLengthValue;
            }
            signal.WaveDataLength = value;
        }
コード例 #7
0
        /// <summary>
        /// 修改示例实体
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        public OperationResult UpdateDemoEntity(DemoEntityDto dto)
        {
            dto.CheckNotNull("dto");
            if (CheckDemoEntityName(dto.Name, CheckExistsType.Update, dto.Id))
            {
                return(new OperationResult(OperationResultType.ValidError, "名称为“{0}”的示例实体已存在,不能重复添加。".FormatWith(dto.Name)));
            }
            DemoEntity entity = _demoEntityRepository.GetByKey(dto.Id);

            entity = Mapper.Map(dto, entity);
            return(_demoEntityRepository.Update(entity) > 0
                ? new OperationResult(OperationResultType.Success, "示例实体“{0}”更新成功。".FormatWith(entity.Name))
                : new OperationResult(OperationResultType.NoChanged));
        }
コード例 #8
0
        public async Task <IActionResult> Add(User model)
        {
            if (ModelState.IsValid)
            {
                var hasModel = _userRepository.GetByKey(model.Id);
                if (model.Id > 0 && hasModel == null)
                {
                    ModelState.AddModelError("", "未找到记录!");
                }
                else
                {
                    if (model.Id > 0)
                    {
                        hasModel.RealName     = model.RealName;
                        hasModel.Phone        = model.Phone;
                        hasModel.RoleId       = model.RoleId;
                        hasModel.LeardId      = model.LeardId;
                        hasModel.Email        = model.Email;
                        hasModel.DepartmentId = model.DepartmentId;
                        _userRepository.Update(hasModel);
                    }
                    else
                    {
                        if (_userRepository.QueryAll().Any(p => p.UserName == model.UserName && p.Disabled == false))
                        {
                            ModelState.AddModelError("", "该用户已经存在!");
                            return(View());
                        }
                        else
                        {
                            model.AddTime = DateTime.Now;
                            await _userManager.CreateAsync(model, model.UserPassword);
                        }
                    }
                    var state = await _unitOfWork.SaveAsync();

                    if (state)
                    {
                        ViewBag.JS = "<script>dialogClose();</script>";
                    }
                    else
                    {
                        ModelState.AddModelError("", "保存失败,请与技术支持联系!");
                    }
                }
            }

            return(View());
        }
コード例 #9
0
 /// <summary>
 /// 根据主键获取id
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public virtual TEntity GetByKey(params object[] id)
 {
     if (null == id)
     {
         throw new ArgumentNullException();
     }
     try
     {
         return(Repository.GetByKey(id));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
コード例 #10
0
ファイル: CategoryService.cs プロジェクト: mike442144/FBS
        public ArticleCategoryDetailsModel GetArticleCategoryById(Guid CategoryID)
        {
            IRepository <ArticleCategory> categoryRep = Factory.Factory <IRepository <ArticleCategory> > .GetConcrete <ArticleCategory>();

            ArticleCategory             tmp    = null;
            ArticleCategoryDetailsModel target = null;

            try
            {
                //tmp = categoryRep.Find(new Specification<ArticleCategory>(c => c.Name == name));
                target = new ArticleCategoryDetailsModel();

                tmp = categoryRep.GetByKey(CategoryID);

                if (tmp == null)
                {
                    return(null);
                }
                target.CategoryName = tmp.Name;
                target.Deepth       = tmp.Deepth;
                target.Description  = tmp.Description;
                target.Icon         = tmp.Icon;
                target.ParentID     = tmp.ParentID;
                target.Priority     = tmp.Priority;
                target.CategoryID   = CategoryID;
            }
            catch
            {
                return(target);
            }

            return(target);
        }
コード例 #11
0
        /// <summary>
        /// 创建人:张辽阔
        /// 创建时间:2016-07-26
        /// 创建记录:验证“批量删除用户信息”的参数是否有效
        /// </summary>
        /// <param name="userID">用户ID</param>
        /// <param name="currentUserID">当前登录用户ID</param>
        /// <returns></returns>
        internal BaseResponse <bool> ValidateDeleteUserParams(List <int> userID, int currentUserID)
        {
            BaseResponse <bool> result = new BaseResponse <bool>();

            result.IsSuccessful = true;
            if (userID == null || !userID.Any())
            {
                result.IsSuccessful = false;
                result.Code         = "004312";
                return(result);
            }
            if (currentUserID <= 0)
            {
                result.IsSuccessful = false;
                result.Code         = "004322";
                return(result);
            }
            if (userRepository.GetByKey(currentUserID) == null)
            {
                result.IsSuccessful = false;
                result.Code         = "004322";
                return(result);
            }

            return(result);
        }
コード例 #12
0
ファイル: GoodsService.cs プロジェクト: mike442144/FBS
        /// <summary>
        /// 获取商品
        /// </summary>
        /// <param name="model">新建商品模型</param>
        public GoodsDetailsModel GetOneGoodsContentByID(Guid aid)
        {
            IRepository <Goods> rep = Factory.Factory <IRepository <Goods> > .GetConcrete <Goods>();

            Goods             goods  = null;
            GoodsDetailsModel target = null;

            try
            {
                goods = rep.GetByKey(aid);

                target = new GoodsDetailsModel()
                {
                    GoodsBeginTime      = goods.GoodsBeginTime,
                    GoodsBuyCount       = goods.GoodsBuyCount,
                    GoodsDetailsContent = goods.GoodsDetailsContent,
                    GoodsEndTime        = goods.GoodsEndTime,
                    GoodsIsOn           = goods.GoodsIsOn,
                    GoodsName           = goods.GoodsName,
                    GoodsNowPrice       = goods.GoodsNowPrice,
                    GoodsOldPrice       = goods.GoodsOldPrice,
                    GoodsPicURL         = goods.GoodsPicURL,
                };
            }

            catch (Exception error)
            {
                throw new Exception(error.Message);
            }

            return(target);
        }
コード例 #13
0
ファイル: HomeController.cs プロジェクト: kcomking1/KCON
        public async Task <IActionResult> ChangePassword([FromBody] UpdatePasswordViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            var adminUser = _userRepository.GetByKey(model.UserId.Value);

            if (adminUser == null)
            {
                return(new JsonResult(new
                {
                    success = false,
                    Message = "修改失败"
                }));
            }
            var pwdVerification = _passwordHasher.VerifyHashedPassword(
                adminUser,
                adminUser.UserPassword,
                model.CurrentPassword);

            if (pwdVerification == PasswordVerificationResult.Success ||
                pwdVerification == PasswordVerificationResult.SuccessRehashNeeded)
            {
                adminUser.UserPassword = _passwordHasher.HashPassword(adminUser, model.NewPassword);
                _userRepository.Update(adminUser);
                var state = await _unitOfWork.SaveAsync();

                return(Json(state));
            }
            return(Json(false));
        }
コード例 #14
0
        public void Initialize()
        {
            //Initialize_data
            User user1 = new User() { Id = 1, Email = "123", CreatedTime = DateTime.Now, Name = "user1", NickName = "梁贵", Password = "******", };
            User user2 = new User() { Id = 2, Email = "123", CreatedTime = DateTime.Now, Name = "user2", NickName = "梁贵2", Password = "******", };
            _users = new List<User> { user1, user2 };

            Role role1 = new Role() { Id = 1, Name = "role1", Remark = "role1" };
            Role role2 = new Role() { Id = 2, Name = "role2", Remark = "role2" };
            _roles = new List<Role> { role1, role2 };
            user1.Roles = _roles;

            //Initialize_interface
            _unitOfWork = Substitute.For<IUnitOfWork>();
            _identityService = Substitute.For<IdentityService>(_unitOfWork);
            _userRepository = Substitute.For<IRepository<User, int>>();
            _roleRepository = Substitute.For<IRepository<Role, int>>();
            _userRepository.GetByKey(Arg.Any<int>()).ReturnsForAnyArgs(x => _users.Find(r => r.Id == (int)x[0]));
            _userRepository.Entities.Returns(_users.AsQueryable());

            _roleRepository.Entities.Returns(_roles.AsQueryable());
            _roleRepository.GetByKey(Arg.Any<int>()).Returns(x => _roles.Find(r => r.Id == (int)x[0]));
            _identityService.UserRepository.Returns(_userRepository);
            _identityService.RoleRepository.Returns(_roleRepository);
        }
コード例 #15
0
        public ProductDataModel GetById(KeyInputModel inputModel)
        {
            var model   = new ProductDataModel();
            var product = _productRepository.GetByKey(inputModel.Id);

            if (product == null)
            {
                throw new ApplicationException("ProductNotFound");
            }
            model = new ProductDataModel
            {
                Id          = product.Id,
                Name        = product.Name,
                Description = product.Description,
                Barcode     = product.Barcode,
                Price       = product.Price,
                Stock       = product.Stock,
                Images      = product.Images.Select(x => new ProductImageDataModel
                {
                    Id       = x.Id,
                    ImageUrl = x.ImageUrl
                }).ToList()
            };
            return(model);
        }
コード例 #16
0
 /// <summary>
 /// 处理简单的删除聚合根的操作。
 /// </summary>
 /// <typeparam name="TAggregateRoot">需要删除的聚合根的类型。</typeparam>
 /// <param name="ids">需要删除的聚合根的ID值列表。</param>
 /// <param name="repository">应用于指定聚合根类型的仓储实例。</param>
 /// <param name="preDelete">在指定聚合根被删除前,对所需删除的聚合根的ID值进行处理的回调函数。</param>
 /// <param name="postDelete">在指定聚合根被删除后,对所需删除的聚合根的ID值进行处理的回调函数。</param>
 protected void PerformDeleteObjects <TAggregateRoot>(IList <string> ids, IRepository <TAggregateRoot> repository, Action <Guid> preDelete = null, Action <Guid> postDelete = null)
     where TAggregateRoot : class, IEntity
 {
     if (ids == null)
     {
         throw new ArgumentNullException("ids");
     }
     if (repository == null)
     {
         throw new ArgumentNullException("repository");
     }
     foreach (var id in ids)
     {
         var guid = new Guid(id);
         if (preDelete != null)
         {
             preDelete(guid);
         }
         var ar = repository.GetByKey(guid);
         repository.Remove(ar);
         if (postDelete != null)
         {
             postDelete(guid);
         }
     }
     repository.Context.Commit();
 }
コード例 #17
0
        public string GetDevice(int id)
        {
            string result   = string.Empty;
            var    monitors = monitorTreeRepository.GetDatas <MonitorTree>(t => true, false).ToList();
            List <MonitorTreeType> mtTypes = monitorTreeTypeRepository.GetDatas <MonitorTreeType>(t => true, true).ToList();
            Device device = deviceRepository.GetByKey(id);

            if (device != null)
            {
                GetYunyiInterfaceData getData = new GetYunyiInterfaceData();
                int siteCount = measureSiteRepository.GetDatas <MeasureSite>(t => t.DevID == device.DevID, true).Count();
                result = Json.Stringify(getData.GetDevice(device, monitors, siteCount, mtTypes, ""));
            }

            return(result);
        }
コード例 #18
0
ファイル: ApplicationService.cs プロジェクト: xudong114/CRM
 protected void F_Delete <AggregateRoot>(IdList ids,
                                         IRepository <AggregateRoot> repository,
                                         Action <Guid> preDeleteAction,
                                         Action <Guid> postDeleteAction)
     where AggregateRoot : class, IAggregateRoot
 {
     if (ids == null)
     {
         throw new ArgumentNullException("ids is null.");
     }
     if (repository == null)
     {
         throw new ArgumentNullException("repository is null.");
     }
     foreach (var id in ids)
     {
         if (preDeleteAction != null)
         {
             preDeleteAction(id);
         }
         var entity = repository.GetByKey(id);
         repository.Delete(entity);
         if (postDeleteAction != null)
         {
             postDeleteAction(id);
         }
     }
     repository.Context.Commit();
 }
コード例 #19
0
        /// <summary>
        /// 获取广告详细内容
        /// </summary>
        /// <param name="model">新建广告模型</param>
        public AdvertisementDetailsModel GetOneAdvertisementContentByID(Guid aid)
        {
            IRepository <Advertisement> rep = Factory.Factory <IRepository <Advertisement> > .GetConcrete <Advertisement>();

            Advertisement             advertisement = null;
            AdvertisementDetailsModel target        = null;

            try
            {
                advertisement = rep.GetByKey(aid);

                target = new AdvertisementDetailsModel()
                {
                    AdvertisementType       = advertisement.AdvertisementType,
                    AdvertisementContentURL = advertisement.AdvertisementContentURL,
                    AdvertisementPriority   = advertisement.AdvertisementPriority,
                    AdvertisementBeginTime  = advertisement.AdvertisementBeginTime,
                    AdvertisementEndTime    = advertisement.AdvertisementEndTime,
                    AdvertisementURL        = advertisement.AdvertisementURL,
                };
            }

            catch (Exception error)
            {
                throw new Exception(error.Message);
            }

            return(target);
        }
コード例 #20
0
                private static CoinProfileData GetCoinProfileData(Guid coinId)
                {
                    IRepository <CoinProfileData> repository = NTMinerRoot.CreateLocalRepository <CoinProfileData>();
                    var result = repository.GetByKey(coinId);

                    return(result);
                }
コード例 #21
0
        public async Task EntityFrameworkRepositoryTests_SaveAndLoadAggregateRootTestAsync()
        {
            EFCustomer customer = new EFCustomer
            {
                Address  = new EFAddress("China", "SH", "SH", "A street", "12345"),
                UserName = "******",
                Password = "******"
            };
            IRepository <EFCustomer> customerRepository = ServiceLocator.Instance.GetService <IRepository <EFCustomer> >();

            customerRepository.Add(customer);
            await customerRepository.Context.CommitAsync();

            var        key       = customer.ID;
            EFCustomer customer2 = customerRepository.GetByKey(key);

            customerRepository.Context.Dispose();

            Assert.AreEqual(customer.UserName, customer2.UserName);
            Assert.AreEqual(customer.Password, customer2.Password);
            Assert.AreEqual(customer.Address.City, customer2.Address.City);
            Assert.AreEqual(customer.Address.Country, customer2.Address.Country);
            Assert.AreEqual(customer.Address.State, customer2.Address.State);
            Assert.AreEqual(customer.Address.Street, customer2.Address.Street);
            Assert.AreEqual(customer.Address.Zip, customer2.Address.Zip);
        }
コード例 #22
0
        /// <summary>
        /// 获取所有置顶帖(全局)
        /// </summary>
        /// <param name="count"></param>
        /// <returns></returns>
        public IList <ThreadsDspModel> FetchTopForumThreadsDspModel(int count)
        {
            IRepository <TopForumThread> rep = Factory.Factory <IRepository <TopForumThread> > .GetConcrete <TopForumThread>();

            IRepository <ThreadRootMessage> msgRep = Factory.Factory <IRepository <ThreadRootMessage> > .GetConcrete <ThreadRootMessage>();

            IList <ThreadsDspModel> mylist = new List <ThreadsDspModel>();
            IList <TopForumThread>  target = new List <TopForumThread>();
            //创建主题仓储
            //IForumThreadRepository forumThreadRep = FBS.Factory.Factory<IForumThreadRepository>.GetConcrete();
            IRepository <ForumThread> forumThreadRep = Factory.Factory <IRepository <ForumThread> > .GetConcrete <ForumThread>();

            IRepository <Account> accRep = Factory.Factory <IRepository <Account> > .GetConcrete <Account>();

            target = rep.FindAll(new Specification <TopForumThread>(c => c.TopForumID == Guid.Empty).OrderByDescending(c => c.CreatTime).Skip(0).Take(count));
            foreach (TopForumThread model in target)
            {
                ForumThread k = forumThreadRep.GetByKey(model.TopForumThreadID);
                if (k != null)
                {
                    k.RootMessage = msgRep.GetByKey(k.RootMessage.Id);

                    mylist.Add(new ThreadsDspModel()
                    {
                        Body = k.RootMessage.MessageVO.Body, ClickCount = k.State.ClickCount, CreationDate = k.CreationDate, ID = k.Id, LastModified = k.ModifiedDate, MessageCount = k.State.MessageCount, Title = k.RootMessage.MessageVO.Subject, UserID = k.RootMessage.Account, UserName = accRep.GetByKey(k.RootMessage.Account).UserName, ForumID = k.ForumID
                    });
                }
            }
            return(mylist);
        }
コード例 #23
0
        /// <summary>
        /// 获取广告页面详细内容
        /// </summary>
        /// <param name="model"></param>
        public AdvertisePageDetailsModel GetOneAdvertisePageByID(Guid aid)
        {
            IRepository <AdvertisePage> rep = Factory.Factory <IRepository <AdvertisePage> > .GetConcrete <AdvertisePage>();

            AdvertisePage             advertisementpage = null;
            AdvertisePageDetailsModel target            = null;

            try
            {
                advertisementpage = rep.GetByKey(aid);

                target = new AdvertisePageDetailsModel()
                {
                    PageDescription = advertisementpage.PageDescription,
                    PageURL         = advertisementpage.PageURL,
                };
            }

            catch (Exception error)
            {
                throw new Exception(error.Message);
            }

            return(target);
        }
コード例 #24
0
        /// <summary>
        /// 获取文章详细内容
        /// </summary>
        /// <param name="aid">文章详细模型</param>
        public ArticleDetailsModel GetOneArticleContentByID(Guid aid)
        {
            IRepository <Article> rep = Factory.Factory <IRepository <Article> > .GetConcrete <Article>();

            IRepository <BlogComment> commentRep = Factory.Factory <IRepository <BlogComment> > .GetConcrete <BlogComment>();


            Article                 article  = null;
            ArticleDetailsModel     target   = null;
            IList <CommentDspModel> comments = null;

            try
            {
                article = rep.GetByKey(aid);
                if (article != null)
                {
                    IList <BlogComment> list = commentRep.FindAll(new Specification <BlogComment>(c => c.TargetId == aid).OrderBy(c => c.CreationDate).Skip(0).Take(10000));
                    if (list != null)
                    {
                        comments = new List <CommentDspModel>();
                        foreach (BlogComment c in list)
                        {
                            CommentDspModel tmp = new CommentDspModel()
                            {
                                AccountID = c.AccountInfo.Id, TargetID = c.TargetId, UserName = c.AccountInfo.UserName, CommentContent = c.Body, CreatedOn = c.CreationDate, CommentID = c.Id
                            };
                            comments.Add(tmp);
                        }
                    }

                    target = new ArticleDetailsModel()
                    {
                        Body         = article.ArticleVO.Body,
                        Title        = article.ArticleVO.Title,
                        CategoryID   = article.CategoryID,
                        CategoryName = article.CategoryName,
                        ClickCount   = article.ArticleVO.ClickCount,
                        CommentCount = article.ArticleVO.CommentCount,
                        CreationDate = article.CreationDate,
                        SourceSite   = article.ArticleVO.SourceSite,
                        SourceUrl    = article.ArticleVO.SourceUrl,
                        UserID       = article.UserID,
                        BriefTitle   = article.ArticleVO.BriefTitle,
                        UserName     = article.UserName,
                        Comments     = comments
                    };
                }
                else
                {
                    return(target);
                }
            }

            catch (Exception error)
            {
                throw new Exception(error.Message);
            }

            return(target);
        }
コード例 #25
0
ファイル: ApplicationService.cs プロジェクト: xudong114/CRM
 protected void F_Delete <DTO, DTOList, AggregateRoot>(DTOList dtoList,
                                                       IRepository <AggregateRoot> repository,
                                                       Action <Guid> preDeleteAction,
                                                       Action <Guid> postDeleteAction)
     where AggregateRoot : class, IAggregateRoot
     where DTO : F_ModelRoot
     where DTOList : List <DTO>
 {
     if (dtoList == null)
     {
         throw new ArgumentNullException("dtoList is null.");
     }
     if (repository == null)
     {
         throw new ArgumentNullException("repository is null.");
     }
     foreach (var dto in dtoList)
     {
         if (preDeleteAction != null)
         {
             preDeleteAction(dto.Id);
         }
         var entity = repository.GetByKey(dto.Id);
         repository.Delete(entity);
         if (postDeleteAction != null)
         {
             postDeleteAction(dto.Id);
         }
     }
     repository.Context.Commit();
 }
コード例 #26
0
ファイル: MessageBuilder.cs プロジェクト: rickeygalloway/Test
        public static EmailTemplate LoadTemplate(IEmailContext context, IRepository<EmailTemplate> emailTemplateRepository)
        {
            try
            {
                EmailTemplate template = null;
                if (context.TemplateId.HasValue)
                {
                    var repository = (EmailTemplateRepository)emailTemplateRepository;
                    template = repository.GetById(context.TemplateId);
                }
                else
                {
                    template = emailTemplateRepository.GetByKey(context.TemplateKey);
                }

                if (template == null)
                {
                    throw new EmailTemplateNotFoundException(context.TemplateKey);
                }
                return template;
            }
            catch (ItemNotFoundException)
            {
                throw new EmailTemplateNotFoundException(context.TemplateKey);
            }
        }
コード例 #27
0
ファイル: BackEnumsController.cs プロジェクト: kcomking1/KCON
        public async Task <IActionResult> Add([FromForm] BackEnum model)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }
            if (model.Id > 0)
            {
                //修改
                var backEnum = _backEnum.GetByKey(model.Id);
                backEnum.ParentId = model.ParentId;
                backEnum.EnumName = model.EnumName;
                backEnum.Remark   = model.Remark;
                backEnum.Sort     = model.Sort;
                _backEnum.Update(backEnum);
            }
            else
            {
                await _backEnum.InsertAsync(model);
            }

            var state = await _unitOfWork.SaveAsync();

            if (state)
            {
                ViewBag.JS = "<script>dialogClose();</script>";
            }
            else
            {
                ModelState.AddModelError("", "保存失败,请与技术支持联系!");
            }

            return(View());
        }
コード例 #28
0
        /// <summary>
        /// 获取广告匹配模型
        /// </summary>
        /// <param name="aid">广告匹配模型编号</param>
        public AdvertiseFillingDspModel GetOneAdvertisementContentByID(Guid aid)
        {
            IRepository <AdvertiseFilling> rep = Factory.Factory <IRepository <AdvertiseFilling> > .GetConcrete <AdvertiseFilling>();

            AdvertiseFilling         advertisement = null;
            AdvertiseFillingDspModel target        = null;

            try
            {
                advertisement = rep.GetByKey(aid);

                target = new AdvertiseFillingDspModel()
                {
                    AdvertisementID = advertisement.AdvertisementID,
                    ID     = advertisement.Id,
                    PageID = advertisement.PageID
                };
            }

            catch (Exception error)
            {
                throw new Exception(error.Message);
            }

            return(target);
        }
コード例 #29
0
ファイル: UserInfoService.cs プロジェクト: mike442144/FBS
        /// <summary>
        /// 用户修改头像
        /// </summary>
        /// <param name="model">修改模型</param>
        public void ModifyUserHead(ModifyUserHeadModel model)
        {
            IRepository <Account> accountRep = Factory.Factory <IRepository <Account> > .GetConcrete <Account>();

            Account usr = accountRep.GetByKey(model.UserID);

            string subDir = System.DateTime.Now.ToString("yyyyMMdd");

            //生成两种尺寸头像
            //ImageResizer ir = new ImageResizer("~/usrimg/", "~/usrimg/"+subDir+"/");
            PanoramaCutting pc   = new PanoramaCutting("~/usrimg/", "~/usrimg/" + subDir + "/");
            string          head = pc.GetImage(model.UserHead, 172, 124);
            string          tiny = pc.GetImage(model.UserHead, 50, 50);

            //可能会再加入回复框中显示的标准,即第三种情况

            //Utils.Tools.CreateThumbForFile("~/usrimg/"+subDir+"/"+Guid.NewGuid().ToString().Replace('-',''),);
            //修改头像
            usr.AccountMsgVO = new
                               AccountMessageVO(
                model.UserID,
                usr.UserName,
                subDir + "/" + head,
                subDir + "" + tiny,
                usr.Points);

            //usr.UserHead = subDir +"/"+ head;
            //usr.Tiny = subDir +"/"+ tiny;

            //更新
            accountRep.Update(usr);
            accountRep.PersistAll();
        }
コード例 #30
0
        public static IWrappedResponse Delete <TEntity>(this IRepository <TEntity> repository, int id)
            where TEntity : class
        {
            var entity = repository.GetByKey(id);

            if (entity == null)
            {
                return(new WrappedResponse()
                {
                    ResultType = ResultType.NotFound,
                });
            }

            repository.Delete(entity);
            var count = repository.Save();

            // when count is zero but entity was found prior, return delete was successful
            if (count == 0)
            {
                return(new WrappedResponse()
                {
                    ResultType = ResultType.Deleted,
                });
            }

            return(new WrappedResponse()
            {
                ResultType = ResultType.Deleted,
            });
        }
コード例 #31
0
ファイル: AdminService.cs プロジェクト: maincotech/erp
        public async Task <ProductDto> GetProduct(Guid id)
        {
            var entity = _productRepository.GetByKey(id);

            if (entity == null)
            {
                return(default);
コード例 #32
0
        /// <summary>
        /// 获取广告详细内容
        /// </summary>
        /// <param name="model">新建广告模型</param>
        public DemandDetailsModel GetOneDemandContentByID(Guid aid)
        {
            IRepository <Demand> rep = Factory.Factory <IRepository <Demand> > .GetConcrete <Demand>();

            Demand             demand = null;
            DemandDetailsModel target = null;

            try
            {
                demand = rep.GetByKey(aid);

                target = new DemandDetailsModel()
                {
                    BusinessmanName      = demand.BusinessmanName,
                    CustomerName         = demand.CustomerName,
                    CustomerOtherConnect = demand.CustomerOtherConnect,
                    CustomerPhoneNum     = demand.CustomerPhoneNum,
                    DemandCity           = demand.DemandCity,
                    DemandContent        = demand.DemandContent,
                    GroupOnType          = demand.GroupOnType,
                };
            }

            catch (Exception error)
            {
                throw new Exception(error.Message);
            }

            return(target);
        }