Пример #1
0
        // The id parameter name should match the DataKeyNames value set on the control
        public void GridViewMyChannels_UpdateItem(int ChannelId)
        {
            TwitterEntities context = new TwitterEntities();

            Twitter.Models.Channel item = null;
            // Load the item here, e.g. item = MyDataLayer.Find(id);
            item = context.Channels.Find(ChannelId);
            if (item == null)
            {
                // The item wasn't found
                ModelState.AddModelError("", String.Format("Item with id {0} was not found", ChannelId));
                return;
            }
            TryUpdateModel(item);
            if (ModelState.IsValid)
            {
                try
                {
                    Verificator.ValidateChannel(item.Name);
                    context.SaveChanges();
                    ErrorSuccessNotifier.AddInfoMessage("Channel updated successfully");
                }
                catch (Exception ex)
                {
                    ErrorSuccessNotifier.AddErrorMessage(ex.Message);
                }
                // Save changes here, e.g. MyDataLayer.SaveChanges();
            }
        }
Пример #2
0
        // The id parameter name should match the DataKeyNames value set on the control
        public void GridViewMyChannels_UpdateItem(int ChannelId)
        {
            TwitterEntities context = new TwitterEntities();

            Twitter.Models.Channel item = null;
            // Load the item here, e.g. item = MyDataLayer.Find(id);
            item = context.Channels.Find(ChannelId);
            if (item == null)
            {
                // The item wasn't found
                ModelState.AddModelError("", String.Format("Item with id {0} was not found", ChannelId));
                return;
            }
            TryUpdateModel(item);
            if (ModelState.IsValid)
            {
                context.SaveChanges();

                // Save changes here, e.g. MyDataLayer.SaveChanges();
            }
        }