public HttpResponseMessage Post(RegisterModel register)
        {
            register.Date = DateTime.UtcNow;

            registerService.Add(register);

            return Request.CreateResponse(HttpStatusCode.OK, "Ponto registrado com sucesso.");
        }
        public RegisterModel Add(RegisterModel register)
        {
            using (var appontoContext = new AppontoContext())
            {
                RegisterModel lastRegister = LoadCurrentDay(register.Date, register.User.Id, true).FirstOrDefault();

                if (lastRegister != null)
                {
                    register.IdLastRegister = lastRegister.Id;
                }

                register.Gmt = register.User.Gmt;

                tb_register tbRegister = ToDbModel(register);
                appontoContext.tb_register.Add(tbRegister);
                appontoContext.SaveChanges();

                RegisterModel ret = ToModel(tbRegister);

                return ret;
            }
        }
        private tb_register ToDbModel(RegisterModel register)
        {
            tb_register tbRegister = new tb_register();

            tbRegister.id_register = register.Id;
            tbRegister.id_last_register = register.IdLastRegister;
            tbRegister.dt_register = register.Date;
            tbRegister.vl_latitude = register.Latitude;
            tbRegister.vl_longitude = register.Longitude;
            tbRegister.ds_host = register.Host;
            tbRegister.vl_gmt = register.Gmt;

            if (register.User.Configuration.ConfigurationLimitation.LimitationType != null)
            {
                tbRegister.tb_limitation_type_id_limitation_type = register.User.Configuration.ConfigurationLimitation.LimitationType.Id;
                tbRegister.id_limitation_type = register.User.Configuration.ConfigurationLimitation.LimitationType.Id;
            }

            if (register.Action != null)
                tbRegister.tb_action_id_action = register.Action.Id;

            if (register.User != null)
                tbRegister.tb_user_id_user = register.User.Id;

            return tbRegister;
        }
        private RegisterModel ToModel(tb_register tbRegister)
        {
            RegisterModel register = new RegisterModel();

            register.Id = tbRegister.id_register;
            if (tbRegister.id_last_register != null)
                register.IdLastRegister = (int)tbRegister.id_last_register;
            if (tbRegister.dt_register != null)
            {
                register.Date = (DateTime)tbRegister.dt_register.Value.AddHours(Double.Parse(tbRegister.vl_gmt.ToString()));
            }

            if (tbRegister.vl_latitude != null)
                register.Latitude = (double)tbRegister.vl_latitude;
            if (tbRegister.vl_longitude != null)
                register.Longitude = (double)tbRegister.vl_longitude;
            register.Host = tbRegister.ds_host;

            if (tbRegister.id_limitation_type != null)
                register.IdLimitationType = (int)tbRegister.id_limitation_type;

            if(tbRegister.tb_action != null)
                register.Action = new ActionModel() { Id = tbRegister.tb_action.id_action, Name = tbRegister.tb_action.ds_action };

            if (tbRegister.vl_gmt != null)
                register.Gmt = (int)tbRegister.vl_gmt;

            if (tbRegister.tb_user != null)
                register.User = new UserModel() { Id = tbRegister.tb_user.id_user, Name = tbRegister.tb_user.ds_name, LastName = tbRegister.tb_user.ds_lastname, Email = tbRegister.tb_user.ds_email };

            return register;
        }