Exemplo n.º 1
0
 private void UpdateUser(string currUsr)
 {
     if (currUsr == null)
     {
         currUsr = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
         Exists  = false;
     }
     try
     {
         this.currentUser = context.Approvers.Where(x => x.WindowsName == currUsr).First();
         Exists           = true;
     }
     catch
     {
         context.Add(new Approver()
         {
             Email = "blank", Name = "Anonymous", ValidAccess = 0, Title = "Anonymous User", WindowsName = currUsr
         });
         context.SaveChanges();
         this.currentUser = context.Approvers.Where(x => x.WindowsName == currUsr).First();
     }
 }
Exemplo n.º 2
0
        public bool Update(string ID, string key, string value)
        {
            if (context.ProcessCards.Any(x => x.ID == int.Parse(ID)))
            {
                var pcA = context.ProcessCards.Where(x => x.ID == int.Parse(ID)).Include("DataPoints").ToList();
                var pc  = pcA.First().DataPoints.Where(x => x.Key == key);
                if (pc.Any())
                {
                    var newDataPoint = new DataPoint()
                    {
                        Key          = pc.First().Key,
                        Value        = value,
                        Approver     = context.Approvers.Where(x => x.Name == userAccess.Name).First(),
                        ApprovedDate = DateTime.Now,
                        Type         = pc.First().Type,
                    };

                    pcA.First().DataPoints.Add(newDataPoint);
                    context.SaveChanges();
                    return(true);
                }
            }
            return(false);
        }