Example #1
0
 private void button1_Click(object sender, EventArgs e)
 {
     WFMModelContainer m = new WFMModelContainer();
     m.GPUCauseSet.Add(new GPUCause());
     m.SaveChanges();
     var emp = m.EmployeeSet.FirstOrDefault(em => em.UserName == "admin");
 }
 /// <summary>
 /// reads user role from database
 /// </summary>
 public static string GetUserRole(string userName)
 {            
     using (var dm = new WFMModelContainer())
     {
         var emp = dm.EmployeeSet.FirstOrDefault(e => e.UserName == userName);
         return emp == null ? "uknown" : emp.Role;
     }
 }
 public HttpResponseMessage NewDocCount(string parameters)
 {
     int cnt = 0;
     // прочитать в базе если пора
     WFMModelContainer db = new WFMModelContainer();
     foreach (var st in db.GPUStopSet.Where(s => s.CauseDoc == null).ToArray())
         cnt++;
     db.Dispose();
     HttpContext.Current.Application.Contents.Set("DocCount", cnt);
     
     object storedCount = HttpContext.Current.Application.Contents.Get("DocCount");
     if (storedCount!=null)
         cnt = (int)storedCount;
     // ответить
     var response = new HttpResponseMessage(HttpStatusCode.OK);
     response.Content = new StringContent(cnt.ToString());
     return response;
 }