public async Task <Repository> CreateRepository(Repository repository) { var url = EnterpriseApiUrls.CreateRepositories(Connection.Credentials.Login); var request = new BitbucketRestRequest(url, Method.POST); var enterpriseRepo = new EnterpriseRepository() { Name = repository.Name, IsPublic = !repository.IsPrivate }; request.AddParameter("application/json; charset=utf-8", request.JsonSerializer.Serialize(enterpriseRepo), ParameterType.RequestBody); var response = await RestClient.ExecuteTaskAsync <EnterpriseRepository>(request); return(response.Data.MapTo <Repository>()); }
///// <summary> ///// 逻辑删除企业信息 ///// </summary> ///// <param name="enterinfo"></param> ///// <returns></returns> //public async Task<OperationResult> LogicDeleteEnterprises(params EnterpriseInfo[] enterinfos) //{ // enterinfos.CheckNotNull("enterinfos"); // int count = 0; // try // { // EnterpriseRepository.UnitOfWork.BeginTransaction(); // count = await EnterpriseRepository.RecycleAsync(enterinfos); // EnterpriseRepository.UnitOfWork.Commit(); // } // catch (DataException dataException) // { // return new OperationResult(OperationResultType.Error, dataException.Message); // } // catch (OSharpException osharpException) // { // return new OperationResult(OperationResultType.Error, osharpException.Message); // } // List<string> names = new List<string>(); // foreach (var data in enterinfos) // { // names.Add(data.EnterpriseName); // } // return count > 0 // ? new OperationResult(OperationResultType.Success, // names.Count > 0 // ? "信息“{0}”逻辑删除成功".FormatWith(names.ExpandAndToString()) // : "{0}个信息逻辑删除成功".FormatWith(count)) // : new OperationResult(OperationResultType.NoChanged); //} /// <summary> /// 物理删除企业信息 /// </summary> /// <param name="ids"></param> /// <returns></returns> public async Task<OperationResult> DeleteEnterprises(params Guid[] ids) { ids.CheckNotNull("ids"); foreach (var id in ids) { int count = EntSiteInfoRepository.Entities.Where(m => m.Enterprise.Id == id).Count(); if (count > 0) { return new OperationResult(OperationResultType.Error, "企业数据关联厂区信息,不能被删除。"); } } EnterpriseRepository.UnitOfWork.BeginTransaction(); var result = await EnterpriseRepository.DeleteAsync(ids); EnterpriseRepository.UnitOfWork.Commit(); return result; }
/// <summary> /// 更新企业信息 /// </summary> /// <param name="inputDtos"></param> /// <returns></returns> public async Task<OperationResult> UpdateEnterprises(params EnterpriseInfoInputDto[] inputDtos) { inputDtos.CheckNotNull("inputDtos"); foreach (EnterpriseInfoInputDto dtoData in inputDtos) { if (string.IsNullOrEmpty(dtoData.EnterpriseCode)) return new OperationResult(OperationResultType.Error, "请正确填写企业编号!"); if (string.IsNullOrEmpty(dtoData.EnterpriseName)) return new OperationResult(OperationResultType.Error, "请正确填写企业名称!"); if (EnterpriseRepository.CheckExists(x => x.EnterpriseCode == dtoData.EnterpriseCode && x.Id != dtoData.Id /*&& x.IsDeleted == false*/)) return new OperationResult(OperationResultType.Error, "该企业编号已存在,无法保存!"); if (EnterpriseRepository.CheckExists(x => x.EnterpriseName == dtoData.EnterpriseName && x.Id != dtoData.Id /*&& x.IsDeleted == false*/)) return new OperationResult(OperationResultType.Error, "该企业名称已存在,无法保存!"); } EnterpriseRepository.UnitOfWork.BeginTransaction(); var result = await EnterpriseRepository.UpdateAsync(inputDtos); EnterpriseRepository.UnitOfWork.Commit(); return result; }
public EnterpriseModel(DbContext dbContext) : base(dbContext) { enterpriseRepository = new EnterpriseRepository(dbContext); }
public EnterpriseController() { EnterRepo = new EnterpriseRepository(); }
public EnterpriseBLL(ApiDbContext context) { repo = new EnterpriseRepository(context); }
/// <summary> /// 检查企业信息是否存在 /// </summary> /// <param name="predicate"></param> /// <param name="id"></param> /// <returns></returns> public bool CheckEnterpriseExists(Expression<Func<EnterpriseInfo, bool>> predicate, Guid id) { return EnterpriseRepository.CheckExists(predicate, id); }
public EnterpriseController(EnterpriseContext context) { _enterpriseRepository = new EnterpriseRepository(context); }