Exemplo n.º 1
0
        public ActionResult DeleteConfirmed(long id)
        {
            PlanetsPost planets = _planetsService.GetPost(id);

            planets.UserName = User.Identity.Name;
            _planetsService.Delete(planets);
            return(RedirectToAction("Index"));
        }
Exemplo n.º 2
0
        public ActionResult Edit([Bind("ixPlanet,sPlanet,ixPlanetarySystem")] PlanetsPost planets)
        {
            if (ModelState.IsValid)
            {
                planets.UserName = User.Identity.Name;
                _planetsService.Edit(planets);
                return(RedirectToAction("Index"));
            }
            ViewBag.ixPlanetarySystem = new SelectList(_planetsService.selectPlanetarySystems().Select(x => new { x.ixPlanetarySystem, x.sPlanetarySystem }), "ixPlanetarySystem", "sPlanetarySystem", planets.ixPlanetarySystem);

            return(View(planets));
        }
Exemplo n.º 3
0
        public ActionResult Edit(long id)
        {
            PlanetsPost planets = _planetsService.GetPost(id);

            if (planets == null)
            {
                return(NotFound());
            }
            ViewBag.ixPlanetarySystem = new SelectList(_planetsService.selectPlanetarySystems().Select(x => new { x.ixPlanetarySystem, x.sPlanetarySystem }), "ixPlanetarySystem", "sPlanetarySystem", planets.ixPlanetarySystem);

            return(View(planets));
        }
Exemplo n.º 4
0
        public Task Delete(PlanetsPost planetsPost)
        {
            // Additional validations

            // Pre-process

            // Process
            this._planetsRepository.RegisterDelete(planetsPost);
            try
            {
                this._planetsRepository.Commit();
            }
            catch (Exception ex)
            {
                this._planetsRepository.Rollback();
                // Log exception
                throw;
            }

            // Post-process

            return(Task.CompletedTask);
        }
Exemplo n.º 5
0
        public Task <Int64> Create(PlanetsPost planetsPost)
        {
            // Additional validations

            // Pre-process

            // Process
            this._planetsRepository.RegisterCreate(planetsPost);
            try
            {
                this._planetsRepository.Commit();
            }
            catch (Exception ex)
            {
                this._planetsRepository.Rollback();
                // Log exception
                throw;
            }

            // Post-process

            return(Task.FromResult(planetsPost.ixPlanet));
        }
 public void RegisterDelete(PlanetsPost planetsPost)
 {
     _context.PlanetsPost.Remove(planetsPost);
 }
 public void RegisterEdit(PlanetsPost planetsPost)
 {
     _context.Entry(planetsPost).State = EntityState.Modified;
 }
 public void RegisterCreate(PlanetsPost planetsPost)
 {
     _context.PlanetsPost.Add(planetsPost);
 }