Esempio n. 1
0
        public async Task <AppraisalForm> UpdateAsync(AppraisalForm updatedAppraisalForm)
        {
            var result = await _AppraisalForms.ReplaceOneAsync(appraisalForm => appraisalForm.Id == updatedAppraisalForm.Id, updatedAppraisalForm);

            if (result.ModifiedCount > 0)
            {
                return(await Task.FromResult(updatedAppraisalForm));
            }
            return(await Task.FromException <AppraisalForm>(new KeyNotFoundException(string.Format("AppraisalForm: {0} was not found", updatedAppraisalForm.Title))));
        }
        public async Task <IActionResult> Put([FromBody] AppraisalForm updatedAppraisalForm)
        {
            try
            {
                var updated = await _appraisalFormRepository.UpdateAsync(updatedAppraisalForm);

                return(Ok(updated));
            }
            catch (KeyNotFoundException) {
                return(NotFound(new EmptyResult()));
            }
        }
Esempio n. 3
0
        public async Task <AppraisalForm> CreateAsync(AppraisalForm newAppraisalForm)
        {
            await _AppraisalForms.InsertOneAsync(newAppraisalForm);

            return(await Task.FromResult <AppraisalForm>(newAppraisalForm));
        }
        public async Task <IActionResult> Post([FromBody] AppraisalForm newAppraisalForm)
        {
            var createdAppraisalForm = await _appraisalFormRepository.CreateAsync(newAppraisalForm);

            return(Ok(createdAppraisalForm));
        }