Example #1
0
        public ActionResult Create([Bind(Include = "userId,FirstName,LastName")] User user)
        {
            if (ModelState.IsValid)
            {
                user.userId = Guid.NewGuid();
                db.Users.Add(user);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(user));
        }
        protected override Employee PatchEntity(int key, Delta <Employee> patch)
        {
            var employeeToPatch = GetEntityByKey(key);

            patch.Patch(employeeToPatch);
            db.Entry(employeeToPatch).State = EntityState.Modified;
            db.SaveChanges();
            var    changedProperty = patch.GetChangedPropertyNames().ToList()[0];
            object changedPropertyValue;

            patch.TryGetPropertyValue(changedProperty, out changedPropertyValue);
            Hub.Clients.All.updateEmployee(employeeToPatch.Id, changedProperty, changedPropertyValue);
            return(employeeToPatch);
        }
Example #3
0
 //Add or Edit DevTest
 internal bool Submit(DevTest objDevtest)
 {
     if (objDevtest.Id > 0) //Edit
     {
         DevTest devTestModel;
         using (var _dbContext = new SignalRContext())
         {
             devTestModel = _dbContext.DevTests.FirstOrDefault(p => p.Id == objDevtest.Id);
             if (devTestModel == null)
             {
                 return(false);
             }
         }
         using (var _dbContext = new SignalRContext())
         {
             _dbContext.Entry(objDevtest).State = System.Data.Entity.EntityState.Modified;
             if (_dbContext.SaveChanges() > 0)
             {
                 return(true);
             }
         }
     }
     else //Add
     {
         using (var _dbContext = new SignalRContext())
         {
             _dbContext.DevTests.Add(objDevtest);
             if (_dbContext.SaveChanges() > 0)
             {
                 return(true);
             }
         }
     }
     return(false);
 }
Example #4
0
 public void Send(string name, string message, string groupName)
 {
     Clients.Group(groupName).addMessageToGroup(name, message, groupName);
     _db.GroupMessages.Add(new GroupMessage {
         User = name, Name = groupName, Message = message
     });
     _db.SaveChanges();
     //groupMessage.Add(new GroupMessage { User = name, Name = groupName, Message = message });
     //Clients.AllExcept(Context.ConnectionId).addNewMessageToGroup(groupMessage);
 }
Example #5
0
 internal bool DeleteById(int id)
 {
     using (var _dbContext = new SignalRContext())
     {
         var devtestModel = _dbContext.DevTests.FirstOrDefault(p => p.Id == id);
         if (devtestModel != null)
         {
             _dbContext.DevTests.Remove(devtestModel);
             if (_dbContext.SaveChanges() > 0)
             {
                 return(true);
             }
         }
     }
     return(false);
 }
 public void Commit()
 {
     _db.SaveChanges();
     _transaction.Complete();
 }