protected BaseJsonApiController( IJsonApiOptions jsonApiOptions, ILoggerFactory loggerFactory, IGetAllService <T, TId> getAll = null, IGetByIdService <T, TId> getById = null, IGetRelationshipService <T, TId> getRelationship = null, IGetRelationshipsService <T, TId> getRelationships = null, ICreateService <T, TId> create = null, IUpdateService <T, TId> update = null, IUpdateRelationshipService <T, TId> updateRelationships = null, IDeleteService <T, TId> delete = null) { _jsonApiOptions = jsonApiOptions; _logger = loggerFactory.CreateLogger <BaseJsonApiController <T, TId> >(); _getAll = getAll; _getById = getById; _getRelationship = getRelationship; _getRelationships = getRelationships; _create = create; _update = update; _updateRelationships = updateRelationships; _delete = delete; _logger.LogTrace("Executing constructor."); }
public GenericController(IRepository <TEntity> repository, IMapper mapper, ICreateService <TEntity, TCreate> createService, IUpdateService <TEntity, TUpdate> updateService) { this.repository = repository; this.mapper = mapper; this.createService = createService; this.updateService = updateService; }
public ChargeLevelsController() { readService = new ReadService(); updateService = new UpdateService(); createService = new CreateService(); deleteService = new DeleteService(); }
/// <summary> /// Creates an instance from separate services for the various individual read and write methods. /// </summary> protected BaseJsonApiController( IJsonApiOptions options, ILoggerFactory loggerFactory, IGetAllService <TResource, TId> getAll = null, IGetByIdService <TResource, TId> getById = null, IGetSecondaryService <TResource, TId> getSecondary = null, IGetRelationshipService <TResource, TId> getRelationship = null, ICreateService <TResource, TId> create = null, IUpdateService <TResource, TId> update = null, IUpdateRelationshipService <TResource, TId> updateRelationships = null, IDeleteService <TResource, TId> delete = null) { if (loggerFactory == null) { throw new ArgumentNullException(nameof(loggerFactory)); } _options = options ?? throw new ArgumentNullException(nameof(options)); _traceWriter = new TraceLogWriter <BaseJsonApiController <TResource, TId> >(loggerFactory); _getAll = getAll; _getById = getById; _getSecondary = getSecondary; _getRelationship = getRelationship; _create = create; _update = update; _updateRelationships = updateRelationships; _delete = delete; }
public ActionResult PostDetails(Comment comment, ICreateService service, IDetailService serviceDetail) { if (!ModelState.IsValid) { //model errors so return immediately return(View(new DetailPostViewModels { Comment = comment, DetailPostDto = serviceDetail.GetDetail <DetailPostDto>(comment.PostId).Result })); } var response = service.Create(comment); if (response.IsValid) { TempData["message"] = response.SuccessMessage; return(RedirectToAction("PostDetails")); } //else errors, so copy the errors over to the ModelState and return to view response.CopyErrorsToModelState(ModelState, comment); return(View(new DetailPostViewModels { Comment = comment, DetailPostDto = serviceDetail.GetDetail <DetailPostDto>(comment.PostId).Result })); }
/// <summary> /// Creates an instance from separate services for the various individual read and write methods. /// </summary> protected BaseJsonApiController( IJsonApiOptions options, ILoggerFactory loggerFactory, IGetAllService <TResource, TId> getAll = null, IGetByIdService <TResource, TId> getById = null, IGetSecondaryService <TResource, TId> getSecondary = null, IGetRelationshipService <TResource, TId> getRelationship = null, ICreateService <TResource, TId> create = null, IAddToRelationshipService <TResource, TId> addToRelationship = null, IUpdateService <TResource, TId> update = null, ISetRelationshipService <TResource, TId> setRelationship = null, IDeleteService <TResource, TId> delete = null, IRemoveFromRelationshipService <TResource, TId> removeFromRelationship = null) { ArgumentGuard.NotNull(options, nameof(options)); ArgumentGuard.NotNull(loggerFactory, nameof(loggerFactory)); _options = options; _traceWriter = new TraceLogWriter <BaseJsonApiController <TResource, TId> >(loggerFactory); _getAll = getAll; _getById = getById; _getSecondary = getSecondary; _getRelationship = getRelationship; _create = create; _addToRelationship = addToRelationship; _update = update; _setRelationship = setRelationship; _delete = delete; _removeFromRelationship = removeFromRelationship; }
public CreateProcessor(ICreateService <TResource, TId> service, ILocalIdTracker localIdTracker, IResourceContextProvider resourceContextProvider) { _service = service ?? throw new ArgumentNullException(nameof(service)); _localIdTracker = localIdTracker ?? throw new ArgumentNullException(nameof(localIdTracker)); _resourceContextProvider = resourceContextProvider ?? throw new ArgumentNullException(nameof(resourceContextProvider)); }
/// <inheritdoc /> public DtoController(IGetService <Dto> getService, ICreateService <Dto, DtoCreate> createService, IUpdateService <Dto, DtoUpdate> updateService, IPatchService <Dto, DtoUpdate> patchService, IDeleteService <Dto> deleteService) : base(getService, createService, updateService, patchService, deleteService) { }
public CreateOpProcessor( ICreateService <T, int> service, IJsonApiDeSerializer deSerializer, IDocumentBuilder documentBuilder, IResourceGraph resourceGraph ) : base(service, deSerializer, documentBuilder, resourceGraph) { }
public AllServiceBase(string url, ResponseToken token, string endpoint) : base(url, token, endpoint) { this.ListService = new ListServiceBase <TResponse>(url, token, endpoint); this.DeleteService = new DeleteServiceBase <TResponse>(url, token, endpoint); this.GetService = new GetServiceBase <TResponse>(url, token, endpoint); this.CreateService = new CreateServiceBase <TRequest, TResponse>(url, token, endpoint); this.UpdateService = new UpdateServiceBase <TRequest, TResponse>(url, token, endpoint); }
public CreateOpProcessor( ICreateService <T, int> service, IJsonApiDeSerializer deSerializer, IDocumentBuilder documentBuilder, IContextGraph contextGraph ) : base(service, deSerializer, documentBuilder, contextGraph) { }
public StockController(ICreateService createService, IUpdateService updateService, IDeleteService deleteService, IShowDataService showDataService) { this.createService = createService; this.updateService = updateService; this.deleteService = deleteService; this.showDataService = showDataService; }
public PostPutDeleteBaseJsonApiController( IJsonApiContext jsonApiContext, IResourceService <T, TId> resourceService) : base(jsonApiContext, resourceService) { _create = resourceService; _update = resourceService; _delete = resourceService; }
//20170209 add by liwei1 for P001-170203001 ===end=== private void InsertMR(DateTime report_datetime, string category, string recommendedOperations, DependencyObjectCollection resultColl, object docId) //20170209 modi by liwei1 for P001-170124001 增加参数:docId { DataTable dt = QueryForMoReceiptReq(report_datetime, category, recommendedOperations, docId); //20170209 modi by liwei1 for P001-170124001 增加参数:docId ValidateParaFilDoc(dt); //20161213 add by shenbao for B001-161213006 DataTable dt_d = QueryForMoReceipt_D(category, report_datetime, recommendedOperations); if (dt.Rows.Count > 0) { IQueryService qrySrv = GetService <IQueryService>();//20170405 add by wangrm for P001-170328001 ICreateService createSrv = GetService <ICreateService>("MO_RECEIPT_REQUISTION"); DependencyObject entity = createSrv.Create() as DependencyObject; ISaveService saveService = this.GetService <ISaveService>("MO_RECEIPT_REQUISTION"); List <IGrouping <object, DataRow> > groupDt = dt_d.AsEnumerable().GroupBy(a => (a.Field <object>("MO_RECEIPT_REQUISTION_ID"))).ToList(); IEFNETStatusStatusService efnetSrv = this.GetService <IEFNETStatusStatusService>(); IDocumentNumberGenerateService docNumberService = this.GetService <IDocumentNumberGenerateService>("MO_RECEIPT_REQUISTION"); foreach (DataRow dr in dt.Rows) { DependencyObject newEntity = new DependencyObject(entity.DependencyObjectType); DependencyObjectCollection newEntityDColl = newEntity["MO_RECEIPT_REQUISTION_D"] as DependencyObjectCollection; AddToEntity(newEntity, dr, dt.Columns, false); newEntity["DOC_NO"] = docNumberService.NextNumber(dr["DOC_ID"], dr["DOC_DATE"].ToDate().Date); List <IGrouping <object, DataRow> > entityDColl = groupDt.Where(c => c.Key.Equals(dr["MO_RECEIPT_REQUISTION_ID"])).ToList(); foreach (IGrouping <object, DataRow> groupDColl in entityDColl) { foreach (DataRow dr_d in groupDColl) { DependencyObject newEntityD = new DependencyObject(newEntityDColl.ItemDependencyObjectType); AddToEntity(newEntityD, dr_d, dt_d.Columns, true); newEntityDColl.Add(newEntityD); } } //20170428 add by wangyq for P001-170427001 ============begin========== DependencyObject resultObj = resultColl.AddNew(); resultObj["doc_no"] = newEntity["DOC_NO"]; //20170428 add by wangyq for P001-170427001 ============end========== //20170628 modi by zhangcn for P001-170327001 ===begin=== try { SetIgnoreWarningTag(); //忽略警告 saveService.Save(newEntity); //希望触发保存校验 } finally { ResetIgnoreWarningTag();// 重置警告 } //20170628 modi by zhangcn for P001-170327001 ===end=== //7.3自动签核 efnetSrv.GetFormFlow("MO_RECEIPT_REQUISTION.I01", dr["DOC_ID"], dr["Owner_Org_ROid"], new List <object>() { dr["MO_RECEIPT_REQUISTION_ID"] }); } } }
/// <summary> /// /// </summary> /// <param name="counting_type">盘点类型</param> /// <param name="site_no">营运据点</param> /// <param name="counting_no">盘点计划编号</param> /// <param name="scan"></param> public void UpdateCountingPlan(string counting_type, string site_no, string counting_no, DependencyObjectCollection scan) { if (string.IsNullOrEmpty(counting_no)) { IInfoEncodeContainer infoContainer = this.GetService <IInfoEncodeContainer>(); throw new BusinessRuleException(string.Format(infoContainer.GetMessage("A111201"), "counting_no")); } using (IConnectionService connectionService = this.GetService <IConnectionService>()) { _qurService = this.GetService <IQueryService>(); CreateTempTable(); //创建临时表 InsertToScan(site_no, scan); //临时表储存scan入参 QueryNode queryScan = QueryScan(counting_no); QueryNode querySumNode = QuerySumForInsert(counting_no, queryScan); DependencyObjectCollection sumColl = _qurService.ExecuteDependencyObject(querySumNode); List <DependencyObject> newList = new List <DependencyObject>(); ISaveService saveService = this.GetService <ISaveService>("COUNTING"); if (sumColl.Count > 0) //查询存在记录新增实体COUNTING { ICreateService createSrv = GetService <ICreateService>("COUNTING"); DependencyObject entity = createSrv.Create() as DependencyObject; newList = InsertCOUNTING(counting_type, counting_no, sumColl, entity.DependencyObjectType); } ICreateService createSrvParaFil = this.GetService <ICreateService>("PARA_FIL"); QueryNode updateNode = null; QueryNode insertNode = null; if (createSrvParaFil != null) //表示该typekey存在 { bool bcManagement = GetBcInventoryManagement(); if (bcManagement) { QueryNode querySumBarcodeNode = QuerySumBarcode(counting_no, queryScan); updateNode = GetUpdateNode(counting_type, counting_no, querySumBarcodeNode); insertNode = QueryNodeForInsert(counting_no, counting_type, querySumBarcodeNode); } } using (ITransactionService transActionService = this.GetService <ITransactionService>()) { if (newList.Count > 0) { SetIgnoreWarningTag(true); saveService.Save(newList.ToArray()); SetIgnoreWarningTag(false); } //更新条码盘点计划 if (updateNode != null) //启用条码库存管理更新 { _qurService.ExecuteNoQueryWithManageProperties(updateNode); } //新增条码盘点计划 if (insertNode != null) //启用条码库存管理更新 { _qurService.ExecuteNoQueryWithManageProperties(insertNode); } transActionService.Complete(); } } }
public PostPutDeleteBaseJsonApiController( IJsonApiContext jsonApiContext, IResourceQueryService <T, TId> queryService = null, IResourceCmdService <T, TId> cmdService = null) : base(jsonApiContext, queryService) { _create = cmdService; _update = cmdService; _delete = cmdService; }
public AppOverrideCreateServiceTest() { var db = new DbContextOptionsBuilder <ApiDbContext>(); db.UseInMemoryDatabase("AppOverrideCreateServiceTest"); context = new ApiDbContext(db.Options); appOverrideConverter = new Mock <IConverter <AppOverrideRequest, AppOverride> >(); responseConverter = new Mock <IConverter <AppOverride, AppOverrideResponse> >(); victim = new AppOverrideCreateService(context, appOverrideConverter.Object, responseConverter.Object); }
public ToggleController(ICreateService <ToggleRequest, ToggleResponse> createService, IReadService <ToggleRequest, ToggleResponse> readService, IUpdateService <ToggleRequest> updateService, IDeleteService <ToggleRequest> deleteService) { _createService = createService; _readService = readService; _updateService = updateService; _deleteService = deleteService; }
public AppOverrideController(ICreateService <AppOverrideRequest, AppOverrideResponse> createService, IReadService <AppOverrideRequest, AppOverrideResponse> readService, IUpdateService <AppOverrideRequest> updateService, IDeleteService <AppOverrideRequest> deleteService) { _createService = createService; _readService = readService; _updateService = updateService; _deleteService = deleteService; }
public CreateProcessor(ICreateService <TResource, TId> service, ILocalIdTracker localIdTracker, IResourceContextProvider resourceContextProvider) { ArgumentGuard.NotNull(service, nameof(service)); ArgumentGuard.NotNull(localIdTracker, nameof(localIdTracker)); ArgumentGuard.NotNull(resourceContextProvider, nameof(resourceContextProvider)); _service = service; _localIdTracker = localIdTracker; _resourceContextProvider = resourceContextProvider; }
public UserService( IQueryService <User> userQueryService, ICreateService <User> userCreateService, IUpdateService <User> userUpdateService, IDeleteService <User> userDeleteService) { _userQueryService = userQueryService; _userCreateService = userCreateService; _userUpdateService = userUpdateService; _userDeleteService = userDeleteService; }
protected WriteController(IGetService <TModel> getService, ICreateService <TModel, TCreateModel> createService, IUpdateService <TModel, TUpdateModel> updateService, IPatchService <TModel, TUpdateModel> patchService, IDeleteService <TModel> deleteService) : base(getService) { CreateService = createService; UpdateService = updateService; PatchService = patchService; DeleteService = deleteService; }
public RoomController(ILogger <RoomController> logger, IGetService <IRoomContainer, DomainRoom> roomGetService, IUpdateService <RoomUpdateModel, IRoomContainer, DomainRoom> roomUpdateService, ICreateService <RoomUpdateModel, IRoomContainer, DomainRoom> roomCreateService, IDeleteService <IRoomContainer> roomDeleteService, IMapper mapper) { Logger = logger; RoomGetService = roomGetService; RoomUpdateService = roomUpdateService; RoomCreateService = roomCreateService; RoomDeleteService = roomDeleteService; Mapper = mapper; }
public PostPutDeleteBaseJsonApiController( IJsonApiContext jsonApiContext, IGetAllService <T, TId> getAll = null, IGetByIdService <T, TId> getById = null, ICreateService <T, TId> create = null, IUpdateService <T, TId> update = null, IDeleteService <T, TId> delete = null ) : base(jsonApiContext, getAll, getById) { _create = create; _update = update; _delete = delete; }
public JsonApiController( IJsonApiContext jsonApiContext, IGetAllService <T, int> getAll = null, IGetByIdService <T, int> getById = null, IGetRelationshipService <T, int> getRelationship = null, IGetRelationshipsService <T, int> getRelationships = null, ICreateService <T, int> create = null, IUpdateService <T, int> update = null, IUpdateRelationshipService <T, int> updateRelationships = null, IDeleteService <T, int> delete = null ) : base(jsonApiContext, getAll, getById, getRelationship, getRelationships, create, update, updateRelationships, delete) { }
public PaymentController(ILogger <PaymentController> logger, IGetService <IPaymentContainer, DomainPayment> paymentGetService, IUpdateService <PaymentUpdateModel, IPaymentContainer, DomainPayment> paymentUpdateService, ICreateService <PaymentUpdateModel, IPaymentContainer, DomainPayment> paymentCreateService, IDeleteService <IPaymentContainer> paymentDeleteService, IMapper mapper) { Logger = logger; PaymentGetService = paymentGetService; PaymentUpdateService = paymentUpdateService; PaymentCreateService = paymentCreateService; PaymentDeleteService = paymentDeleteService; Mapper = mapper; }
public BookingController(ILogger <BookingController> logger, IGetService <IBookingContainer, DomainBooking> bookingGetService, IUpdateService <BookingUpdateModel, IBookingContainer, DomainBooking> bookingUpdateService, ICreateService <BookingUpdateModel, IBookingContainer, DomainBooking> bookingCreateService, IDeleteService <IBookingContainer> bookingDeleteService, IMapper mapper) { Logger = logger; BookingGetService = bookingGetService; BookingUpdateService = bookingUpdateService; BookingCreateService = bookingCreateService; BookingDeleteService = bookingDeleteService; Mapper = mapper; }
public ClientController(ILogger <ClientController> logger, IGetService <IClientContainer, Client> clientGetService, IUpdateService <ClientUpdateModel, IClientContainer, Client> clientUpdateService, ICreateService <ClientUpdateModel, IClientContainer, Client> clientCreateService, IDeleteService <IClientContainer> clientDeleteService, IMapper mapper) { Logger = logger; ClientGetService = clientGetService; ClientUpdateService = clientUpdateService; ClientCreateService = clientCreateService; ClientDeleteService = clientDeleteService; Mapper = mapper; }
public void creatTmp(string TypeKey, out DataTable dt, out DependencyObjectType targetType) { dt = null; targetType = null; string[] spiltTypeKeys = null; bool isColls = false; string primaryKey = string.Empty; if (TypeKey.Contains(@".")) { spiltTypeKeys = TypeKey.Split(new[] { '.' }); TypeKey = spiltTypeKeys[0]; primaryKey = spiltTypeKeys[spiltTypeKeys.Length - 2]; isColls = true; } ICreateService createSrv = Provider.GetService(typeof(ICreateService), TypeKey) as ICreateService; if (createSrv == null) { return; } var entity = createSrv.Create() as DependencyObject; DependencyObjectType toType = entity.DependencyObjectType; if (isColls && spiltTypeKeys != null) { spiltTypeKeys.ToList().ForEach(key => { if (!key.Equals(TypeKey)) { toType = ((ICollectionProperty)(toType.Properties[key])).ItemDataEntityType as DependencyObjectType; } }); } IBusinessTypeService businessTypeSrv = Provider.GetService(typeof(IBusinessTypeService), CallContext.TypeKey) as IBusinessTypeService; targetType = RegiesterType(toType, targetType); if (isColls) { string primaryKeyName = primaryKey + "_ID"; targetType.RegisterSimpleProperty(primaryKeyName, businessTypeSrv.SimplePrimaryKeyType, null, false, new Attribute[] { businessTypeSrv.SimplePrimaryKey }); } dt = CreateDt(targetType, dt); }
public ResourceController( IJsonApiOptions jsonApiOptions, ILoggerFactory loggerFactory, IGetAllService <Resource, int> getAll = null, IGetByIdService <Resource, int> getById = null, IGetRelationshipService <Resource, int> getRelationship = null, IGetRelationshipsService <Resource, int> getRelationships = null, ICreateService <Resource, int> create = null, IUpdateService <Resource, int> update = null, IUpdateRelationshipService <Resource, int> updateRelationships = null, IDeleteService <Resource, int> delete = null) : base(jsonApiOptions, loggerFactory, getAll, getById, getRelationship, getRelationships, create, update, updateRelationships, delete) { }
public ActionResult Create(Blog blog, ICreateService service) { if (!ModelState.IsValid) //model errors so return immediately return View(blog); var response = service.Create(blog); if (response.IsValid) { TempData["message"] = response.SuccessMessage; return RedirectToAction("Index"); } //else errors, so copy the errors over to the ModelState and return to view response.CopyErrorsToModelState(ModelState, blog); return View(blog); }
public ActionResult AddAddress(CrudCustomerAddressDto customerAddress, ICreateService service) { if (!ModelState.IsValid) //model errors so return immediately return View(customerAddress); var response = service.Create(customerAddress); if (response.IsValid) { TempData["message"] = response.SuccessMessage; return RedirectToAction("Details", new { id = customerAddress.CustomerID }); } //else errors, so copy the errors over to the ModelState and return to view response.CopyErrorsToModelState(ModelState, customerAddress); return View(customerAddress); }
public ActionResult Create(CrudCustomerDto customer, ICreateService service) { if (!ModelState.IsValid) //model errors so return immediately return View(customer); var response = service.Create(customer); if (response.IsValid) { TempData["message"] = response.SuccessMessage + " You must now assign a password to this customer."; return RedirectToAction("NotCustomers"); } //else errors, so copy the errors over to the ModelState and return to view response.CopyErrorsToModelState(ModelState, customer); return View(customer); }
public JsonResult AjaxAddLineItem(CreateLineItemDto newOrder, ICreateService service) { if (!ModelState.IsValid) { //model errors so return errors return ModelState.ReturnModelErrorsAsJson(); } var response = service.Create(newOrder); if (response.IsValid) { return Json(new { SuccessMessage = response.SuccessMessage }); } //else errors, so send back the errors return response.ReturnErrorsAsJson(newOrder); }
public ActionResult NewOrder(NewOrderDto newOrder, ICreateService service) { if (!ModelState.IsValid) { //model errors so return immediately service.ResetDto(newOrder); return View(newOrder); } var response = service.Create(newOrder); if (response.IsValid) { //no success message as in a process return RedirectToAction("EditLineItems", new { salesOrderId = newOrder.SalesOrderID}); } //else errors, so copy the errors over to the ModelState and return to view response.CopyErrorsToModelState(ModelState, newOrder); return View(newOrder); }