public UserEntity Add(UserEntity user)
        {
            UserTableRepository userTableRepository = new UserTableRepository(dbContext);

            userTableRepository.Add(user);
            return(user);
        }
示例#2
0
        public IHttpActionResult Add([FromUri(Name = "n")] string name, [FromUri(Name = "u")] string url, [FromUri(Name = "v")] string version, [FromUri(Name = "t")] string theme = "", [FromUri(Name = "l")] string lines = "", [FromUri(Name = "a")] string highlight = "")
        {
            var request = HttpContext.Current.Request;

            try
            {
                url  = Utils.Reverse(url);
                name = Utils.Reverse(name);

                var entry = new Entry(name, url)
                {
                    Version   = version,
                    Agent     = request.UserAgent,
                    IpAddress = request.UserHostAddress
                };

                try
                {
                    var hostInfo = Dns.GetHostEntry(IPAddress.Parse(request.UserHostAddress));

                    entry.HostName = hostInfo.HostName;
                }
                catch { }

                var svc = new EntryService();

                svc.AddEntry(entry);

                var userSvc = new UserTableRepository();

                userSvc.AddOrUpdate(new User(name, version, theme, lines, highlight));
            }
            catch (Exception ex)
            {
                var telemetry = new ExceptionTelemetry(ex);

                telemetry.Properties.Add("message", ex.Message);
                telemetry.Properties.Add("userName", name);
                telemetry.Properties.Add("url", url);
                telemetry.Properties.Add("requestUrl", request.Url.AbsoluteUri.ToString());

                telemetryClient.TrackException(telemetry);
            }

            return(Ok("data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"));
        }
        public IEnumerable <UserEntity> GetUserOrangeList()
        {
            UserTableRepository userTableRepository = new UserTableRepository(dbContext);

            return(userTableRepository.GetUserOrangeList());
        }
        public UserEntity Put(UserEntity user)
        {
            UserTableRepository userTableRepository = new UserTableRepository(dbContext);

            return(userTableRepository.Put(user));
        }
        public UserEntity Delete(int id)
        {
            UserTableRepository userTableRepository = new UserTableRepository(dbContext);

            return(userTableRepository.Delete(id));
        }