Exemplo n.º 1
0
        public Message LeaveOpinion(string id, string rating, string comment)
        {
            SvcContext ctx = InflateContext(); if (ctx.Invalid)

            {
                return(ctx.ContextMessage);
            }

            try
            {
                var objID = Guid.ParseExact(id, "N");
                var obj   = AppLookups.GetCacheIndexEntry(objID);

                var opinion = new ContentService().CreateOpinion(new Opinion()
                {
                    Comment  = comment,
                    ObjectID = obj.ID, Rating = byte.Parse(rating)
                }, obj.ID);

                var by  = CfPerfCache.GetClimber(CfIdentity.UserID);
                var dto = new OpinionDto(opinion, by);

                return(ReturnAsJson(dto));
            }
            catch (Exception ex)
            {
                return(Failed("Opinion failed : " + ex.Message));
            }
        }
Exemplo n.º 2
0
        public IActionResult Create([FromBody] OpinionDto opinionDto)
        {
            var opinion = _mapper.Map <Opinion>(opinionDto);

            try
            {
                _opinionService.Create(opinion);
                return(Ok());
            }
            catch (AppException ex)
            {
                return(BadRequest(ex.Message));
            }
        }