示例#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);
        }
示例#2
0
        /// <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);
        }
示例#3
0
        public async Task <BaseComponentResultRp> UpdateCustomer(int id, CustomerPutRp model)
        {
            var result    = new BaseComponentResultRp();
            var createdBy = this._identityGateway.GetIdentity();

            this._dbContext.ChangeTracker.AutoDetectChangesEnabled = true;

            var customer = await this._dbContext.Customers.SingleAsync(c => c.Id == id);

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

            customer.Update(this._datetimeGateway.GetCurrentDateTime(), createdBy,
                            model.Name,
                            model.Avatar,
                            model.Leaders);

            this._dbContext.Update(customer);

            await this._dbContext.SaveChangesAsync();

            return(result);
        }
示例#4
0
        /// <summary>
        /// Delete appsetting
        /// </summary>
        /// <param name="key">AppSetting Keg</param>
        /// <returns></returns>
        public async Task <BaseComponentResultRp> DeleteAppSetting(string key)
        {
            var result = new BaseComponentResultRp();

            var appSetting = await this._dbContext.AppSettings.FirstOrDefaultAsync(c => c.Key.Equals(key));

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

            this._dbContext.Remove(appSetting);

            await this._dbContext.SaveChangesAsync();

            return(result);
        }
示例#5
0
        /// <summary>
        /// Delete Squad
        /// </summary>
        /// <param name="key">Squad Id</param>
        /// <returns></returns>
        public async Task <BaseComponentResultRp> DeleteSquad(int id)
        {
            var result     = new BaseComponentResultRp();
            var modifiedBy = this._identityGateway.GetIdentity();

            var squad = await this._dbContext.Squads.SingleAsync(c => c.Id == id);

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

            this._dbContext.Squads.Remove(squad);

            await this._dbContext.SaveChangesAsync();

            return(result);
        }
示例#6
0
        /// <summary>
        /// Update appsetting
        /// </summary>
        /// <param name="model">AppSetting Model</param>
        /// <returns></returns>
        public async Task <BaseComponentResultRp> UpdateAppSetting(string key, AppSettingPutRp model)
        {
            var result     = new BaseComponentResultRp();
            var appSetting = await this._dbContext.AppSettings.FirstOrDefaultAsync(c => c.Key.Equals(key));

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

            appSetting.Value      = model.Value;
            appSetting.ModifiedBy = this._identityGateway.GetIdentity();
            appSetting.ModifiedOn = DateTime.UtcNow;

            this._dbContext.Update(appSetting);
            await this._dbContext.SaveChangesAsync();

            return(result);
        }
示例#7
0
        public async Task <BaseComponentResultRp> DeleteMember(int memberId)
        {
            var result    = new BaseComponentResultRp();
            var createdBy = this._identityGateway.GetIdentity();

            this._dbContext.ChangeTracker.AutoDetectChangesEnabled = true;

            var member = await this._dbContext.Members.SingleAsync(c => c.Id == memberId);

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

            this._dbContext.Members.Remove(member);
            await this._dbContext.SaveChangesAsync();

            return(result);
        }
        /// <summary>
        /// Update appsetting
        /// </summary>
        /// <param name="model">AppSetting Model</param>
        /// <returns></returns>
        public async Task <BaseComponentResultRp> UpdateAppSetting(string key, AppSettingPutRp model)
        {
            var result     = new BaseComponentResultRp();
            var appSetting = await this._appSettingRepository.GetAppSettingByKey(key);

            if (appSetting == null)
            {
                result.AddNotFound($"The Key {key} doesn't exists.");
                return(result);
            }

            appSetting.Value     = model.Value;
            appSetting.UpdatedBy = this._identityService.GetIdentity();
            appSetting.UpdatedOn = DateTime.UtcNow;

            this._appSettingRepository.Update(appSetting);

            await this._appSettingRepository.SaveChanges();

            return(result);
        }