public ActionResult Create(AtractionDb atractionDb)
        {
            if (ModelState.IsValid)
            {
                db.AtractionDb.Add(atractionDb);
                db.SaveChanges();

                return(RedirectToAction("Index"));
            }

            return(View(atractionDb));
        }
        public ActionResult Create(City city)
        {
            if (ModelState.IsValid)
            {
                var MiastaDodane = db.City.ToList().Where(c => c.Name.Equals("Id"));
                db.City.Add(city);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(city));
        }
 public bool Save()
 {
     try
     {
         // return how many row changes were made (as long as it is greater than 0
         return(_ctx.SaveChanges() > 0);
     }
     catch (Exception ex)
     {
         // to do - log error
         return(false);
     }
 }
示例#4
0
        static void Main(string[] args)
        {
            /* User u = new User()
             * {
             *   LastName = "jebari",
             *   FirstName = "mayssa",
             *   Login="******",
             *   Password="******",
             *   Address = "benarouss",
             *   DateOfBirth = new DateTime(0080, 10, 10),
             *   TelephoneNumber = "12584",
             *   ImageUrl = "url"
             *
             *
             *
             *
             * };*/


            MapContext ctx = new MapContext();

            //ctx.UserS.Add(u);



            ctx.SaveChanges();
            Console.WriteLine("Base Created with succes ");
            Console.ReadKey();
        }
示例#5
0
        public ActionResult Delete(Mapper input)
        {
            Mapper mDelete = _mapdb.Mappers.Find(input.Id);

            _mapdb.Mappers.Remove(mDelete);
            _mapdb.SaveChanges();
            return(Json(new { input.Id }));
        }
示例#6
0
        public ActionResult Create([Bind(Include = "RequestID,requiredProfile,NbRequiredProfile,yearExperience,Education,DateStart_Mandat,DateEnd_Mandat")] Request request)
        {
            if (ModelState.IsValid)
            {
                System.Security.Principal.WindowsIdentity.GetCurrent();
                request.stateRequest = StateRequest.Pending;
                request.DateDeposit  = DateTime.Now;
                request.userId       = Int32.Parse(User.Identity.GetUserId());
                if (reqS.DateCorrect(request))
                {
                    db.RequestS.Add(request);
                    db.SaveChanges();
                }
                return(RedirectToAction("Index"));
            }

            return(View(request));
        }
示例#7
0
 public ActionResult Edit([Bind(Include = "RequestID,requiredProfile,NbRequiredProfile,yearExperience,Education,DateDeposit,DateStart_Mandat,DateEnd_Mandat,stateRequest,userId")] Request request)
 {
     if (ModelState.IsValid)
     {
         db.Entry(request).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(request));
 }
示例#8
0
        public static void Initialize(MapContext context)
        {
            context.Database.EnsureCreated();

            var gridCells = GetGridCells();
            var clusters  = GetAllClusters();
            var servers   = GetAllServers(gridCells);

            context.AddRange(gridCells);
            context.AddRange(clusters);
            context.AddRange(servers);
            context.SaveChanges();
        }
        public ActionResult <Rumor> PostRumor(Rumor rumor)
        {
            try
            {
                var query = mapDb.Rumors.FirstOrDefault(s => s.Title == rumor.Title || s.RumorId == rumor.RumorId);
                if (query != null)
                {
                    return(BadRequest("ID已存在!"));
                }

                var date = DateCalculator.StringToDate(rumor.Date);
                rumor.CrawlTime = DateCalculator.DateToTicks(date);

                mapDb.Rumors.Add(rumor);
                mapDb.SaveChanges();

                return(rumor);
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }
        }
示例#10
0
 public IActionResult Post(ButtonInfo buttonInfo)
 {
     try
     {
         var button = db.Map.FirstOrDefault(x => x.Id == buttonInfo.Id);
         button.Value = buttonInfo.Value;
         db.SaveChanges();
         TicTacToe.Instance.MakeTurn(buttonInfo.Id, buttonInfo.Value, LogicTransfer.Instance);
         return(Ok(LogicTransfer.Instance.GameState));
     }
     catch
     {
         return(StatusCode(403));
     }
 }
示例#11
0
        public ActionResult Index()
        {
            db.Database.Delete();
            db.SaveChanges();

            PageViewModel vm = new PageViewModel
            {
                UrlMaps   = db.UrlMaps.ToList(),
                Maps      = db.Maps.ToList(),
                Times     = db.Times.ToList(),
                Qualities = db.Qualities.ToList()
            };

            return(View(vm));
        }
示例#12
0
 public void Commit()
 {
     dataContext.SaveChanges();
 }