コード例 #1
0
ファイル: ChoiceController.cs プロジェクト: dsb92/patientcare
        public ActionResult Add(Choice choice)
        {
            try
            {
                var model = _repository.Add(choice);

                return new HttpStatusCodeResult(HttpStatusCode.Created, "New choice was created with id: " + model.ChoiceId);
            }
            catch (Exception ex)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
        }
コード例 #2
0
ファイル: ChoiceRepository.cs プロジェクト: dsb92/patientcare
        public Choice Add(Choice choice)
        {
            try
            {
                var newChoice = new Choice()
                {
                    ChoiceId = ObjectId.GenerateNewId().ToString(),
                    CategoryId = choice.CategoryId,
                    Details = choice.Details,
                    Name = choice.Name
                };

                var returned = _choices.InsertOneAsync(newChoice.ToBsonDocument());
                returned.Wait();
                _log.Debug("New choice added with id: " + newChoice.ChoiceId);
                return newChoice;
            }
            catch (Exception ex)
            {
                _log.Exception(ex.Message + ex.InnerException);
                throw;
            }
        }