Esempio n. 1
0
        public ActionResult Add(Task task)
        {
            if (String.IsNullOrEmpty(task.name))
                ModelState.AddModelError("Name", "Введите свое name");

            if (String.IsNullOrEmpty(task.text))
                ModelState.AddModelError("Text", "Введите свое text");

            if (ModelState.IsValid)
            {
                MyDBDataContext db = new MyDBDataContext();
                MyTable125 item = new MyTable125
                {
                    name = task.name,
                    text = task.text,
                    TaskAdded = DateTime.Now,
                    TaskBegin = task.TaskBegin,
                    TaskEnd = task.TaskEnd,
                    delete = false
                };

                //item.done = !flagDone;

                db.MyTable125.InsertOnSubmit(item);
                db.SubmitChanges();
                return RedirectPermanent("/Home/Index");
            }
            else
                // Обнаружена ошибка проверки достоверности
                return RedirectPermanent("/Home/Index");

            return RedirectPermanent("/Home/Index");
            //return View();
        }
        public ActionResult Edit(int?id, LearningMVC.Models.User userDetails)
        {
            TempData["TempData Name"] = "Akhil";

            try
            {
                var dbContext = new MyDBDataContext();
                var user      = dbContext.Users.FirstOrDefault(userId => userId.UserId == id);
                if (user != null)
                {
                    user.FirstName   = userDetails.FirstName;
                    user.LastName    = userDetails.LastName;
                    user.Address     = userDetails.Address;
                    user.PhoneNo     = userDetails.PhoneNo;
                    user.EMail       = userDetails.EMail;
                    user.Company     = userDetails.Company;
                    user.Designation = userDetails.Designation;
                    dbContext.SubmitChanges();
                }
                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
        //
        // GET: /Show/
        public ActionResult Show()
        {
            List<Task> taskListFalse = new List<Task>();
            List<Task> taskListTrue = new List<Task>();
            List<Task> taskListDelete = new List<Task>();

            MyDBDataContext db = new MyDBDataContext();

            taskListFalse = db.ExecuteQuery<Task>(@"SELECT * FROM [MyTable125] WHERE done = 'false' AND [delete] = 'false'").ToList<Task>();
            //taskListFalse = db.ExecuteQuery<Task>(@"SELECT * FROM [MyTable125] WHERE done = 'false' ").ToList<Task>();
            taskListTrue = db.ExecuteQuery<Task>(@"SELECT * FROM [MyTable125] WHERE done = 'true' AND [delete] = 'false'").ToList<Task>();
            taskListDelete = db.ExecuteQuery<Task>(@"SELECT * FROM [MyTable125] WHERE [delete] = 'true'").ToList<Task>();

            /*
            WriteResult(taskListFalse);
            WriteResult(taskListTrue);
            WriteResult(taskListDelete);
            */

            ThreeModel tm = new ThreeModel();

            tm.taskListFalse = taskListFalse;
            tm.taskListTrue = taskListTrue;
            tm.taskListDelete = taskListDelete;

            return View(tm);
        }
Esempio n. 4
0
        static void AddItem()
        {
            ObjCtx = new MyDBDataContext();
            //Console.WriteLine("enter Item code");
            //int id = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("enter Item Name");
            string name = Console.ReadLine();

            Console.WriteLine("enter price");
            int  pce     = Convert.ToInt32(Console.ReadLine());
            Item itemObj = new Item();

            //itemObj.ItemCode = id;
            itemObj.ItemName = name;
            itemObj.Price    = pce;
            ObjCtx.Items.InsertOnSubmit(itemObj);
            try
            {
                ObjCtx.SubmitChanges();
                Console.WriteLine("inserted...");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Esempio n. 5
0
 public BaseService()
 {
     if (_context == null)
     {
         _context = new MyDBDataContext();
     }
 }
Esempio n. 6
0
        static void ModifyItem(int itemId)
        {
            ObjCtx = new MyDBDataContext();
            Console.WriteLine("Enter new title");
            string name = Console.ReadLine();

            Console.WriteLine("Enter the modified price");
            int pce = Console.Read();

            var mResult = from item in ObjCtx.Items
                          where item.ItemCode == itemId
                          select item;

            foreach (var bk in mResult)
            {
                //bk.bookId = bk.bk
                bk.ItemName = name;
                bk.Price    = pce;
            }
            try
            {
                ObjCtx.SubmitChanges();
                Console.WriteLine("updated...");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Esempio n. 7
0
        public int RegistryMember(Entities.User e)
        {
            try
            {
                using (MyDBDataContext db = new MyDBDataContext())
                {
                    int newUserId = InsertPersonalInformation(db, e);

                    Entities.UserInRole uir = new Entities.UserInRole();
                    uir.RolesId = 8;
                    uir.UserId  = newUserId;
                    uir.State   = false;
                    int memberRoleId = InsertMemberRole(db, uir);
                    if (memberRoleId <= 0)
                    {
                        Delete(newUserId);
                        return(memberRoleId);
                    }

                    return(newUserId);
                }
            }
            catch (Exception ex)
            {
                string data = className + " " + ex.Message.ToString();
                Logs.LogWrite(string.Format(Configs.ERROR_ACTION, data));
                return((int)Enums.Errors.INSERT_ERROR);
            }
        }
Esempio n. 8
0
        public int DoConfirmRegisMember(Entities.User e)
        {
            try
            {
                using (MyDBDataContext db = new MyDBDataContext())
                {
                    DataLayer.User user = (from u in db.Users
                                           where u.Id == e.Id
                                           select u).FirstOrDefault();

                    if (user == null)
                    {
                        return((int)Enums.Errors.NOT_EXIST);
                    }
                    user.Status = e.Status;

                    db.UserInRoles
                    .Where(u => u.UserId == e.Id)
                    .ToList()
                    .ForEach(u => u.State = true);
                    db.SubmitChanges();
                }
                return(e.Id);
            }
            catch (Exception ex)
            {
                string data = className + " " + ex.Message.ToString();
                Logs.LogWrite(string.Format(Configs.ERROR_ACTION, data));
                return((int)Enums.Errors.UPDATE_ERROR);
            }
        }
 /// <summary>
 /// Get Action for Details
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public ActionResult Details(int? id)
 {
     var dbContext = new MyDBDataContext();
     Mapper.CreateMap<LearningMVC.User, LearningMVC.Models.User>();
     var userDetails = dbContext.Users.FirstOrDefault(userId => userId.UserId == id);
     LearningMVC.Models.User user = Mapper.Map<LearningMVC.User, LearningMVC.Models.User>(userDetails);
     return View(user);
 } 
Esempio n. 10
0
        public PredictionHistory(Form obj, Userinfo ui)
        {
            cntx = new MyDBDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=F:\Important Documents\Project\Solution1\OOP2\DotaDB.mdf;Integrated Security=True;Connect Timeout=30");

            InitializeComponent();
            this.obj = obj;
            this.ui  = ui;
        }
        /// <summary>
        /// Get Action for Edit
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult Edit(int?id)
        {
            Mapper.CreateMap <LearningMVC.User, LearningMVC.Models.User>();
            var dbContext   = new MyDBDataContext();
            var userDetails = dbContext.Users.FirstOrDefault(userId => userId.UserId == id);
            var user        = Mapper.Map <LearningMVC.User, LearningMVC.Models.User>(userDetails);

            return(View(user));
        }
Esempio n. 12
0
        void FilterItemsById(int itemid)
        {
            ObjCtx = new MyDBDataContext();
            var mResult = from item in ObjCtx.Items
                          where item.ItemCode == itemid
                          select item;

            foreach (var item in mResult)
            {
                Console.WriteLine(item.ItemCode + " " + item.ItemName + " " + item.Price);
            }
        }
Esempio n. 13
0
        static void ListAllItems()
        {
            ObjCtx = new MyDBDataContext();
            var mResult = from allitem in ObjCtx.Items
                          // where books.price
                          select allitem;

            // displays all available books
            foreach (var item in mResult)
            {
                Console.WriteLine(item.ItemCode + " " + item.ItemName + " " + item.Price);
            }
        }
Esempio n. 14
0
        public ActionResult Hide(int dd, bool flagDelete)
        {
            MyDBDataContext db = new MyDBDataContext();

            MyTable125 item = db.MyTable125.Single(e => e.Id == dd);

            item.delete = !flagDelete;

            db.SubmitChanges();

            return RedirectPermanent("/Home/Index");
            //return View("Index");
            //return View();
        }
 public ActionResult Create(LearningMVC.Models.User userDetails)
 {
     try
     {
         Mapper.CreateMap <LearningMVC.Models.User, LearningMVC.User>();
         var dbContext = new MyDBDataContext();
         var user      = Mapper.Map <LearningMVC.Models.User, LearningMVC.User>(userDetails);
         dbContext.Users.InsertOnSubmit(user);
         dbContext.SubmitChanges();
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
 public ActionResult Create(LearningMVC.Models.User userDetails)
 {
     try
     {
         Mapper.CreateMap<LearningMVC.Models.User, LearningMVC.User>();
         var dbContext = new MyDBDataContext();
         var user = Mapper.Map<LearningMVC.Models.User, LearningMVC.User>(userDetails);
         dbContext.Users.InsertOnSubmit(user);
         dbContext.SubmitChanges();
         return RedirectToAction("Index");
     }
     catch
     {
         return View();
     }
 } 
 /// <summary>
 /// Get Action for index
 /// </summary>
 /// <returns></returns>
 public ActionResult Index()
 {
     Mapper.CreateMap<LearningMVC.User, LearningMVC.Models.User>();
     var dbContext = new MyDBDataContext();
     var userList = from user in dbContext.Users select user;
     var users = new List<LearningMVC.Models.User>();
     if (userList.Any())
     {
         foreach (var user in userList)
         {
             LearningMVC.Models.User userModel = Mapper.Map<LearningMVC.User, LearningMVC.Models.User>(user);
             users.Add(userModel);
         }
     }
   
     return View(users);
 }
        /// <summary>
        /// Get Action for index
        /// </summary>
        /// <returns></returns>
        public ActionResult Index()
        {
            Mapper.CreateMap <LearningMVC.User, LearningMVC.Models.User>();
            var dbContext = new MyDBDataContext();
            var userList  = from user in dbContext.Users select user;
            var users     = new List <LearningMVC.Models.User>();

            if (userList.Any())
            {
                foreach (var user in userList)
                {
                    LearningMVC.Models.User userModel = Mapper.Map <LearningMVC.User, LearningMVC.Models.User>(user);
                    users.Add(userModel);
                }
            }

            return(View(users));
        }
        public ActionResult Delete(int?id, LearningMVC.Models.User userDetails)
        {
            try
            {
                var dbContext = new MyDBDataContext();
                var user      = dbContext.Users.FirstOrDefault(userId => userId.UserId == id);
                if (user != null)
                {
                    dbContext.Users.DeleteOnSubmit(user);
                    dbContext.SubmitChanges();
                }

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Esempio n. 20
0
 public int InsertMemberRole(MyDBDataContext db, Entities.UserInRole e)
 {
     try
     {
         DataLayer.UserInRole u = new DataLayer.UserInRole();
         u.RolesId = e.RolesId;
         u.UserId  = e.UserId;
         u.State   = e.State;
         db.UserInRoles.InsertOnSubmit(u);
         db.SubmitChanges();
         return(u.Id);
     }
     catch (Exception ex)
     {
         string data = className + " " + ex.Message.ToString();
         Logs.LogWrite(string.Format(Configs.ERROR_ACTION, data));
         return((int)Enums.Errors.INSERT_ERROR);
     }
 }
Esempio n. 21
0
        public ActionResult OnInput([Bind(Include = "name, text, TaskBegin, taskEnd")] Task task)
        {
            task.TaskAdded = DateTime.Now;
            //Валидация вводных данных
            if (ModelState.IsValid)
            {
                //Корректные

                MyDBDataContext db = new MyDBDataContext();
                MyTable125 item = new MyTable125
                {
                    name = task.name,
                    text = task.text,
                    TaskAdded = DateTime.Now,
                    TaskBegin = task.TaskBegin,
                    TaskEnd = task.TaskEnd,
                    delete = false
                };

                { }
                //item.done = !flagDone;

                db.MyTable125.InsertOnSubmit(item);
                db.SubmitChanges();

                ViewBag.Sussed = "Успешно добвлен!";

                //return RedirectToAction("Index", "Home");
                //return RedirectPermanent("~/Home/Index");
                //return RedirectPermanent("~/Add/Add");
                return View();
            }
            else
            {
                //Некорректные
                //return RedirectPermanent("~/Home/Index");
                return View("Input");
            }

            //return View();
        }
Esempio n. 22
0
        static void DeleteItem(int itemid)
        {
            ObjCtx = new MyDBDataContext();
            var mResult = from item in ObjCtx.Items
                          where item.ItemCode == itemid
                          select item;

            foreach (var bk in mResult)
            {
                ObjCtx.Items.DeleteOnSubmit(bk);
            }
            try
            {
                ObjCtx.SubmitChanges();
                Console.WriteLine("deleted...");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Esempio n. 23
0
 public int DeleteMultiple(int[] usersDelete)
 {
     try
     {
         using (MyDBDataContext db = new MyDBDataContext())
         {
             db.Users
             .Where(u => usersDelete.Contains(u.Id))
             .ToList()
             .ForEach(u => { u.Delete = true; u.DateUpdate = DateTime.Now; });
             db.SubmitChanges();
         }
         return(1);
     }
     catch (Exception ex)
     {
         string data = className + " " + ex.Message.ToString();
         Logs.LogWrite(string.Format(Configs.ERROR_ACTION, data));
         return((int)Enums.Errors.DELETE_ERROR);
     }
 }
Esempio n. 24
0
 public int InsertPersonalInformation(MyDBDataContext db, Entities.User e)
 {
     try
     {
         DataLayer.User user = new DataLayer.User();
         user.DisplayName = e.DisplayName;
         user.FirstName   = e.FirstName;
         user.LastName    = e.LastName;
         user.Gender      = e.Gender;
         user.DateOfBirth = DateTime.ParseExact(e.DateOfBirth, "dd/MM/yyyy", null);
         user.UserName    = e.UserName;
         user.Email       = e.Email;
         user.Password    = e.Password;
         user.Status      = e.Status;
         user.Description = e.Description;
         user.Delete      = e.Delete;
         user.DateCreate  = DateTime.Now;
         user.DateUpdate  = DateTime.Now;
         user.DateLogin   = DateTime.Now;
         user.PlaceId     = e.PlaceId;
         user.Address     = e.Address;
         user.Zipcode     = e.Zipcode;
         user.CompanyLogo = e.CompanyLogo;
         user.CodeActive  = e.CodeActive;
         user.CompanyName = e.CompanyName;
         user.Phone       = e.Phone;
         user.Avatar      = e.Avatar;
         user.IsUpdated   = false;
         db.Users.InsertOnSubmit(user);
         db.SubmitChanges();
         return(user.Id);
     }
     catch (Exception ex)
     {
         string data = className + " " + ex.Message.ToString();
         Logs.LogWrite(string.Format(Configs.ERROR_ACTION, data));
         return((int)Enums.Errors.INSERT_ERROR);
     }
 }
        private void MatchResult_Load(object sender, EventArgs e)
        {
            UpdateDBLin     ul = new UpdateDBLin();
            MyDBDataContext cntx;

            cntx = new MyDBDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=F:\Important Documents\Project\Solution1\OOP2\DotaDB.mdf;Integrated Security=True;Connect Timeout=30");

            var str = from a in cntx.MResults
                      where a.MatchId == mr.MatchId
                      select a;

            dataGridView1.DataSource = str;

            var st = from a in cntx.MatchPs
                     where a.MatchId == mp.MatchId && a.Username == mp.Username
                     select a;

            dataGridView2.DataSource = st;

            ul.InsertUserPrediction(mp, bs1, bs2, bs3, w1, w2, w3);
            ul.DeletePred(mp.Username, mp.MatchId);
        }
        public ActionResult Delete(int? id, LearningMVC.Models.User userDetails)
        {
            try
            {
                var dbContext = new MyDBDataContext();
                var user = dbContext.Users.FirstOrDefault(userId => userId.UserId == id);
                if (user != null)
                {
                    dbContext.Users.DeleteOnSubmit(user);
                    dbContext.SubmitChanges();
                }

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        } 
Esempio n. 27
0
 public UpdateDBLin()
 {
     this.cntx = new MyDBDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=F:\Important Documents\Project\Solution1\OOP2\DotaDB.mdf;Integrated Security=True;Connect Timeout=30");
 }
        public ActionResult Edit(int? id, LearningMVC.Models.User userDetails)
        {
            TempData["TempData Name"] = "Akhil";

            try
            {
                var dbContext = new MyDBDataContext();
                var user = dbContext.Users.FirstOrDefault(userId => userId.UserId == id);
                if (user != null)
                {
                    user.FirstName = userDetails.FirstName;
                    user.LastName = userDetails.LastName;
                    user.Address = userDetails.Address;
                    user.PhoneNo = userDetails.PhoneNo;
                    user.EMail = userDetails.EMail;
                    user.Company = userDetails.Company;
                    user.Designation = userDetails.Designation;
                    dbContext.SubmitChanges();
                }
                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }