public ActivitySettingDTO ConvertItemToDto(CommunityMetrics_ActivitySetting item)
        {
            ActivitySettingDTO dto = new ActivitySettingDTO();

            dto.id          = item.id;
            dto.activity_id = item.activity_id;
            dto.name        = item.name;
            dto.value       = item.value;

            return(dto);
        }
        public HttpResponseMessage Post(ActivitySettingDTO dto)
        {
            try
            {
                CommunityMetrics_ActivitySetting item = ConvertDtoToItem(null, dto);

                dc.CommunityMetrics_ActivitySettings.InsertOnSubmit(item);
                dc.SubmitChanges();

                return(Request.CreateResponse(HttpStatusCode.OK, ConvertItemToDto(item)));
            }
            catch (Exception ex)
            {
                Exceptions.LogException(ex);
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex));
            }
        }
        public HttpResponseMessage Put(ActivitySettingDTO dto)
        {
            try
            {
                CommunityMetrics_ActivitySetting item = dc.CommunityMetrics_ActivitySettings.Where(i => i.id == dto.id).SingleOrDefault();

                if (item == null)
                {
                    return(Request.CreateResponse(HttpStatusCode.NotFound));
                }

                item = ConvertDtoToItem(item, dto);

                dc.SubmitChanges();

                return(Request.CreateResponse(HttpStatusCode.OK, ConvertItemToDto(item)));
            }
            catch (Exception ex)
            {
                Exceptions.LogException(ex);
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex));
            }
        }
        public CommunityMetrics_ActivitySetting ConvertDtoToItem(CommunityMetrics_ActivitySetting item, ActivitySettingDTO dto)
        {
            if (item == null)
            {
                item = new CommunityMetrics_ActivitySetting();
            }

            if (dto == null)
            {
                return(item);
            }

            item.id          = dto.id.GetValueOrDefault();
            item.activity_id = dto.activity_id.GetValueOrDefault();
            item.name        = dto.name;
            item.value       = dto.value;

            return(item);
        }