コード例 #1
0
        public bool CreateChoices(ChoicesEntites entity)
        {
            Choice newItem = new Choice()
            {
                IdQuestion     = entity.IdQuestion,
                IdChoices      = entity.IdChoices,
                Content        = entity.Content,
                NumericalOrder = entity.NumericalOrder,
                LastEditedAt   = entity.LastEditedAt,
                LastEditedBy   = entity.LastEditedBy
            };

            _unit.ChoiceGenericType.Insert(newItem);
            _unit.Save();
            return(true);
        }
コード例 #2
0
        public bool UpdateChoices(Guid id, ChoicesEntites entity)
        {
            bool success    = false;
            var  updateItem = _unit.ChoiceGenericType.GetByID(id);

            if (updateItem != null)
            {
                updateItem.IdQuestion     = entity.IdQuestion;
                updateItem.Content        = entity.Content;
                updateItem.NumericalOrder = entity.NumericalOrder;
                updateItem.LastEditedAt   = entity.LastEditedAt;
                updateItem.LastEditedBy   = entity.LastEditedBy;

                _unit.ChoiceGenericType.Update(updateItem);
                _unit.Save();
                success = true;
            }
            return(success);
        }
コード例 #3
0
ファイル: ChoicesController.cs プロジェクト: luuthi/Survey
        public JsonResult <APIResultEntities <bool> > Post(ChoicesEntites entity)
        {
            APIResultEntities <bool> rs = new APIResultEntities <bool>();

            try
            {
                _iChoicesServices.CreateChoices(entity);
                rs.Data           = true;
                rs.ErrCode        = ErrorCodeEntites.Success;
                rs.ErrDescription = string.Format(Constants.MSG_INSERT_SUCCESS, Constants.Choices);
            }
            catch (Exception ex)
            {
                rs.Data           = false;
                rs.ErrCode        = ErrorCodeEntites.Fail;
                rs.ErrDescription = ex.ToString();
                throw new Exception(ex.ToString());
            }
            return(Json(rs));
        }