Exemplo n.º 1
0
 public ActionResult Edit(int id, Man_Reward mr)
 {
     if (id == mr.Id)
     {
         db.Entry(mr).State = EntityState.Modified;
         db.SaveChanges();
     }
     return(RedirectToAction("Index", new { id = mr.ManId }));
 }
Exemplo n.º 2
0
        public ActionResult Edit(int id)
        {
            IEnumerable <Reward> rewards = db.Rewards;

            ViewBag.Rewards = rewards;
            Man_Reward EditMr = db.Man_Rewards.Find(id);

            ViewBag.EditMr = EditMr;
            return(View());
        }
Exemplo n.º 3
0
        public ActionResult Delete(int id)
        {
            Man_Reward mr = db.Man_Rewards.Find(id);

            if (mr != null)
            {
                db.Man_Rewards.Remove(mr);
                db.SaveChanges();
            }
            return(RedirectToAction("Index", new { id = mr.ManId }));
        }
Exemplo n.º 4
0
        public ActionResult SyncCSV()
        {
            List <Man_Reward> MRsDisplayStart = new List <Man_Reward>();
            List <Man_Reward> MRsDisplayEnd   = new List <Man_Reward>();

            using (var streamReader = new StreamReader(@"D:\Projects\InteractiveSystem\interactiveSystem\Content\ManReward.csv"))
                using (var reader = new CsvReader(streamReader))
                {
                    reader.ReadHeaderRecord();
                    while (reader.HasMoreRecords)
                    {
                        var      dataRecord = reader.ReadDataRecord();
                        string   row        = dataRecord.ToString();
                        string[] rows       = row.Split(new char[] { ';' });
                        if ((rows[0] != "") && (rows[2] != ""))
                        {
                            Man_Reward MRDisplayStart = new Man_Reward();
                            MRDisplayStart.ManId       = int.Parse(rows[0]);
                            MRDisplayStart.RewardId    = int.Parse(rows[2]);
                            MRDisplayStart.Description = rows[8];
                            if (rows[5] != "")
                            {
                                MRDisplayStart.Date = Convert.ToDateTime(rows[5]);
                            }
                            MRsDisplayStart.Add(MRDisplayStart);
                        }
                    }
                }

            foreach (var e in MRsDisplayStart)
            {
                IEnumerable <Man>    MenDisplayEnd     = db.Men.Where(st => st.IdPersonal == e.ManId);
                IEnumerable <Reward> RewardsDisplayEnd = db.Rewards.Where(st => st.IdRew == e.RewardId);
                if ((MenDisplayEnd.Count() != 0) && (RewardsDisplayEnd.Count() != 0))
                {
                    Man_Reward MRDisplayEnd = new Man_Reward();
                    MRDisplayEnd.ManId       = MenDisplayEnd.First().Id;
                    MRDisplayEnd.RewardId    = RewardsDisplayEnd.First().Id;
                    MRDisplayEnd.Description = e.Description;
                    MRDisplayEnd.Date        = e.Date;
                    MRsDisplayEnd.Add(MRDisplayEnd);
                    db.Man_Rewards.Add(MRDisplayEnd);
                    db.SaveChanges();
                }
            }

            ViewBag.List = MRsDisplayEnd;

            return(View());
        }
Exemplo n.º 5
0
 public ActionResult Add(Man_Reward mr)
 {
     db.Man_Rewards.Add(mr);
     db.SaveChanges();
     return(RedirectToAction("Index", new { id = mr.ManId }));
 }