/// <summary> /// Update or create a single resource or a list of resources, depending on whether the Resource or Resources property has got a value set. /// If the singular property is set a single record will be created or updated and the list of records will be ignored. /// To create or update more than one record, assign a list of values to the multiple property and make sure single value is set to nothing/null. /// </summary> /// <param name="request">The request containing the resource or resources that needs to be created or updated</param> /// <returns>depending on the values supplied, the updated single value or list of values will be returned.</returns> public virtual ResourcesResponse Any(StoreResources request) { //return ExecuteFaultHandledMethod(() => //{ ResourcesResponse response = new ResourcesResponse(); //IResourceRepository _repository = _DataRepositoryFactory.GetDataRepository<IResourceRepository>(); var _repository = _DataRepositoryFactory.GetDataRepository <IGenericEntityRepositoryBase <JarsResource, IDataContextNhJars> >(); response.Resources = _repository.CreateUpdateList(request.Resources.ConvertAllTo <JarsResource>().ToList(), CurrentSessionUsername).ConvertAllTo <ResourceDto>().ToList(); return(response); //}); }
public async Task <IActionResult> EditCategory(int Id, [FromBody] StoreResources productResources) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var product = await context.Stores.SingleOrDefaultAsync(x => x.Id == Id); mapper.Map <StoreResources, Store>(productResources, product); await context.SaveChangesAsync(); product = await context.Stores.SingleOrDefaultAsync(s => s.Id == product.Id); var result = mapper.Map <Store, StoreResources>(product); return(Ok(result)); }
public async Task <IActionResult> CreateCategory([FromBody] StoreResources productResources) { // individualResourses.Id = 0; if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var product = mapper.Map <StoreResources, Store>(productResources); // individual.Id = 0; context.Add(product); await context.SaveChangesAsync(); product = await context.Stores.SingleOrDefaultAsync(s => s.Id == product.Id); var result = mapper.Map <Store, StoreResources>(product); return(Ok(result)); }