Example #1
0
        /// <summary>
        /// Update Feature
        /// </summary>
        /// <param name="model">Feature Model</param>
        /// <returns></returns>
        public async Task <BaseComponentResultRp> UpdateFeature(int id, FeaturePutRp model)
        {
            var result    = new BaseComponentResultRp();
            var createdBy = this._identityGateway.GetIdentity();

            this._dbContext.ChangeTracker.AutoDetectChangesEnabled = true;

            var feature = await this._dbContext.Features.Include(c => c.Product).SingleAsync(c => c.Id == id);

            if (feature == null)
            {
                result.AddNotFound($"The Resource {id} doesn't exists.");
                return(result);
            }


            feature.Update(this._datetimeGateway.GetCurrentDateTime(),
                           createdBy, model.Name,
                           model.Avatar,
                           model.Description);

            this._dbContext.Features.Update(feature);

            await this._dbContext.SaveChangesAsync();

            return(result);
        }
Example #2
0
        public void then_update()
        {
            var representationPut = new FeaturePutRp();

            representationPut.Description = NewValue;

            var jsonContent = HttpClientExtension.ParseModelToHttpContent(representationPut);
            var responsePut = _client.PutAsync(NewResourceLocation, jsonContent).Result;


            Assert.True(StatusCodes.Status200OK == (int)responsePut.StatusCode, responsePut.Content.ReadAsStringAsync().Result);
        }
        public async Task <IActionResult> Put(int id, [FromBody] FeaturePutRp resource)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.BadRequest(this.ModelState));
            }

            var response = await this._featureComponent.UpdateFeature(id, resource);

            if (response.HasNotFounds())
            {
                return(this.NotFound(response.GetNotFounds()));
            }

            if (response.HasConflicts())
            {
                return(this.Conflict(response.GetConflicts()));
            }

            return(this.Ok());
        }