Пример #1
0
        public bool WriteUserToDB(User user)
        {
            MyDataContext dataContext = new MyDataContext();
            var           context     = (IDataContextFactory <HealthDataContext>)dataContext.GetMyDataContextContext(_configuration);

            using (var db = context.Create())
            {
                var lastidquery = (from u in db.Users
                                   //where t.DeliverySelection == true && t.Delivery.SentForDelivery == null
                                   orderby u.Id descending
                                   select u).Take(1);
                int id = 0;

                foreach (var u in lastidquery)
                {
                    id = u.Id + 1;
                }
                if (id != 0)
                {
                    user.Id = id;
                    if (db.Insert(user) > 0)
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Пример #2
0
        //---------------------------------------------------------------------------------

        public IActionResult ShowUsers()
        {
            MyDataContext dataContext = new MyDataContext();
            var           context     = (IDataContextFactory <HealthDataContext>)dataContext.GetMyDataContextContext(_configuration);

            //ViewBag.ListOfUsers = GetAllusers(context);
            return(View("Show", GetAllusers(context)));
        }
Пример #3
0
        //----------------------------------------------------------
        public bool UpdateUserToDB(User user)
        {
            MyDataContext dataContext = new MyDataContext();
            var           context     = (IDataContextFactory <HealthDataContext>)dataContext.GetMyDataContextContext(_configuration);

            using (var db = context.Create())
            {
                if (db.Update(user) > 0)
                {
                    return(true);
                }
            }

            return(false);
        }