コード例 #1
0
        //public async Task<ActionResult> RaceEventEdit([Bind(Include = "Name,Id,Description")] RoleViewModel roleModel)
        public ActionResult RaceEventEdit(RaceEventViewModel raceEventViewModel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    using (var db = new MercuryBackofficeDbContext())
                    {
                        var raceEvent = db.RaceEvent.Where(x => x.EventId.ToString() == raceEventViewModel.EventId.ToString()).SingleOrDefault();

                        if (raceEvent == null)
                        {
                            return(HttpNotFound());
                        }

                        if (raceEvent != null)
                        {
                            raceEvent.EventName      = raceEventViewModel.EventName;
                            raceEvent.Description    = raceEventViewModel.Description;
                            raceEvent.EventOrganiser = raceEventViewModel.EventOrganiser;
                            raceEvent.EventTypeId    = raceEventViewModel.EventTypeId;
                            raceEvent.EventVenue     = raceEventViewModel.EventVenue;
                            raceEvent.EventStartOn   = raceEventViewModel.EventStartOn;
                            raceEvent.EventEndOn     = raceEventViewModel.EventEndOn;
                            raceEvent.IsTimingChip   = raceEventViewModel.IsTimingChip;
                            raceEvent.IsActive       = raceEventViewModel.IsActive;
                            raceEvent.IsCharity      = raceEventViewModel.IsCharity;
                            raceEvent.Latitude       = raceEventViewModel.Latitude;
                            raceEvent.Longitude      = raceEventViewModel.Longitude;
                            raceEvent.FacebookURL    = raceEventViewModel.FacebookURL;
                            raceEvent.GooglePlusURL  = raceEventViewModel.GooglePlusURL;
                            raceEvent.InstagramURL   = raceEventViewModel.InstagramURL;
                            raceEvent.TwitterURL     = raceEventViewModel.TwitterURL;
                            //raceEvent.CreatedOn = DateTime.Now;
                            //raceEvent.CreatedBy = User.Identity.Name;
                            raceEvent.UpdatedOn = DateTime.Now;
                            raceEvent.UpdatedBy = User.Identity.Name;
                        }

                        var result = db.SaveChanges();

                        //if (result)
                        //{
                        return(RedirectToAction(PageURL.url_Race_RaceEvent_List));
                        //}
                    }
                }
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", ex);
                return(View());
            }
            return(View());
        }
コード例 #2
0
        //public async Task<ActionResult> RaceEventTypeEdit([Bind(Include = "Name,Id,Description")] RoleViewModel roleModel)
        public ActionResult RaceEventTypeEdit(RaceEventTypeViewModel raceEventTypeViewModel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    using (var db = new MercuryBackofficeDbContext())
                    {
                        var raceEventType = db.RaceEventType.Where(x => x.EventTypeId.ToString() == raceEventTypeViewModel.EventTypeId.ToString()).SingleOrDefault();

                        if (raceEventType == null)
                        {
                            return(HttpNotFound());
                        }

                        if (raceEventType != null)
                        {
                            raceEventType.EventTypeName = raceEventTypeViewModel.EventTypeName;
                            raceEventType.Description   = raceEventTypeViewModel.Description;
                            raceEventType.IsActive      = raceEventTypeViewModel.IsActive;
                            //raceEventType.CreatedOn = DateTime.Now;
                            //raceEventType.CreatedBy = User.Identity.Name;
                            raceEventType.UpdatedOn = DateTime.Now;
                            raceEventType.UpdatedBy = User.Identity.Name;
                        }

                        var result = db.SaveChanges();

                        //if (result)
                        //{
                        return(RedirectToAction(PageURL.url_Race_RaceEventType_List));
                        //}
                    }
                }
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", ex);
                return(View());
            }
            return(View());
        }