예제 #1
0
        public Guid? CreateJobEntry(entry e, Guid user_token)
        {
            var t = _createJobEntry(e, user_token);
            t.Wait();
            if (t.Result != null)
            {

                return t.Result.id;
            }
            else { return null; }
        }
예제 #2
0
파일: Data.cs 프로젝트: rrrhys/Timeclock
 public Guid? CreateJobEntry(entry e, Guid user_token)
 {
     using (var context = new CWTimeclockEntities())
     {
         var user = context.users.FirstOrDefault(f => f.token == user_token);
         if (user != null)
         {
             e.time_to = DateTime.Now;
             e.user_id = user.id;
             e.id = Guid.NewGuid();
             context.entries.Add(e);
             context.SaveChanges();
             return e.id;
         }
         else
         {
             throw new UserNotFoundException("Couldn't find user for token.");
         }
     }
 }
예제 #3
0
        private async Task<entry> _createJobEntry(entry e, Guid user_token)
        {
            using (var client = GetHttpClient())
            {
                if (e.time_to == DateTime.MinValue)
                {
                    e.time_to = e.time_from;
                }

                var payload = new WrapWithToken { payload = e, user_token = user_token };
                HttpResponseMessage response = client.PostAsJsonAsync(EntrysEndpoint, payload).Result;

                if (response.IsSuccessStatusCode)
                {
                    return await response.Content.ReadAsAsync<entry>();
                }
                else
                {

                }
                return null;
            }
        }
예제 #4
0
        private async Task<bool> _updateEntry(Guid entryToken, string comments, Guid user_token)
        {
            using (var client = GetHttpClient())
            {
                entry E = new entry();
                E.id = entryToken;
                E.time_to = DateTime.Now;
                E.comments = comments;
               

                var payload = new WrapWithToken { payload = E, user_token = user_token };

                HttpResponseMessage response = client.PutAsJsonAsync("/api/entries/?entry_token=" + entryToken.ToString(), payload).Result;
                if (response.IsSuccessStatusCode)
                {
                    return await response.Content.ReadAsAsync<bool>();
                }
            }
            return false;
        }
예제 #5
0
 private void startJob()
 {
     var e = new DataLayer.entry();
     e.work_type_id = cached_work_types.FirstOrDefault(c => c.work_type == cWorkTypes.Text).id;
     e.job_number_id = cached_job_numbers.FirstOrDefault(c => c.job_number == cJobNumber.Text).id;
     e.time_from = DateTime.Now;
     e.comments = tComments.Text;
     currentEntryToken = db.CreateJobEntry(e, user_token.Value);
     lTimeStarted.Text = "Started at " + e.time_from.ToString("HH:mm");
     bStartJob.Enabled = false;
     bFinishJob.Enabled = true;
     this.Icon = new System.Drawing.Icon("1435308138_checkmark_tick.ico");
 }