public async Task <IActionResult> UpdateKeyOutcome(int empId, string KeyResultAreaId, string KeyOutcomeId, JsonPatchDocument <KeyOutcomeForUpdateDto> entityForUpdate)
        {
            var keyOutcomeForUpdate = new KeyOutcomeForUpdateDto();

            entityForUpdate.ApplyTo(keyOutcomeForUpdate);

            ObjectId Id           = new ObjectId(KeyResultAreaId);
            ObjectId keyOutcomeId = new ObjectId(KeyOutcomeId);

            var result = await resultArea.UpdateKeyOutcome(Id, keyOutcomeId, empId, keyOutcomeForUpdate);

            if (result > 0)
            {
                return(Ok(result));
            }

            return(NotFound());
        }
        public async Task <IActionResult> UpdateKeyOutcome(int empId, string coreValueId, string KeyOutcomeId, JsonPatchDocument <KeyOutcomeForUpdateDto> entityForUpdate)
        {
            var keyOutcomeForUpdate = new KeyOutcomeForUpdateDto();

            entityForUpdate.ApplyTo(keyOutcomeForUpdate);

            ObjectId Id           = new ObjectId(coreValueId);
            ObjectId keyOutcomeId = new ObjectId(KeyOutcomeId);

            var result = await coreValueRepo.UpdateCoreValueKeyOutcome(Id, keyOutcomeId, keyOutcomeForUpdate);

            if (result > 0)
            {
                return(CreatedAtAction("CoreValue", new { Id = Id }));
            }

            return(NotFound());
        }
        public async Task <long> UpdateKeyOutcome(ObjectId Id, ObjectId outcomeId, int UserId, KeyOutcomeForUpdateDto entity)
        {
            entity.keyOutcomes.Id = outcomeId;
            var filter = Builders <KeyResultArea> .Filter.Where(r => r.Id == Id && r.EmployeeId == UserId && r.keyOutcomes.Any(a => a.Id == outcomeId));

            var bsonElement = entity.keyOutcomes.ToBsonDocument();
            var update      = Builders <KeyResultArea> .Update.Set("keyOutcomes.$", bsonElement);

            var result = await Collection.UpdateOneAsync(filter, update);

            return(result.ModifiedCount);
        }
示例#4
0
        public async Task <long> UpdateCoreValueKeyOutcome(ObjectId Id, ObjectId keyoutcomeId, KeyOutcomeForUpdateDto coreValue)
        {
            var filter = Builders <CoreValuesKRA> .Filter.Where(r => r.Id == Id);

            var bsonElement = coreValue.keyOutcomes.ToBsonDocument();

            var update = new BsonDocument("$set", bsonElement);

            var result = await Collection.UpdateOneAsync(filter, update);

            return(result.ModifiedCount);
        }