/// <summary>
        /// Update journey
        /// </summary>
        /// <param name="model">journey Model</param>
        /// <returns></returns>
        public async Task <BaseComponentResultRp> Update(int id, JourneyPutRp model)
        {
            var result    = new BaseComponentResultRp();
            var createdBy = this._identityGateway.GetIdentity();

            this._dbContext.ChangeTracker.AutoDetectChangesEnabled = true;

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

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

            journey.Update(this._datetimeGateway.GetCurrentDateTime(), createdBy, model.Name,
                           model.AvailabilitySlo,
                           model.LatencySlo,
                           model.ExperienceSlo,
                           new SLAValue(model.AvailabilitySLA, model.LatencySLA),
                           model.Description,
                           model.Avatar, model.Leaders, model.Group);

            this._dbContext.Journeys.Update(journey);

            await this._dbContext.SaveChangesAsync();

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

            representationPut.Description = NewValue;

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

            Assert.Equal(StatusCodes.Status200OK, (int)responsePut.StatusCode);
        }
Beispiel #3
0
        public async Task <IActionResult> Put(int id, [FromBody] JourneyPutRp resource)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.BadRequest(this.ModelState));
            }

            var response = await this._journeyComponent.Update(id, resource);

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

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

            return(this.Ok());
        }