Beispiel #1
0
        public async Task <Message> EditMessage(string channelId, string messageId, MessageEdit edit)
        {
            if (edit.Content == null && !edit.Embed.HasValue)
            {
                throw new Exception("Expecting MessageEdit to have either content or embed");
            }

            var body = new Dictionary <string, string>();

            if (edit.Content != null)
            {
                body.Add("content", edit.Content);
            }

            if (edit.Embed.HasValue)
            {
                body.Add("embed", JsonConvert.SerializeObject(edit.Embed.Value));
            }

            var response = await ClientToolbox.PatchAsync(DiscordAPI.Message(channelId, messageId), body);

            if (response != null && response.IsSuccessStatusCode)
            {
                Message message = this.client.CreateStructure <Message>(await response.Content.ReadAsStringAsync());

                // TODO: Should be by reference, Client object may be large
                // Inject client
                return(this.InjectClient(ref message));
            }

            return(null);
        }
        public ActionResult Edit(int id, MessageEdit model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            if (model.MessageId != id)
            {
                ModelState.AddModelError("", "Id Mismatch");
                return(View(model));
            }

            var userId  = Guid.Parse(User.Identity.GetUserId());
            var service = new MessageService(userId);

            if (service.UpdateMessage(model, userId))
            {
                TempData["SaveResult"] = "Your message was updated.";
                return(RedirectToAction("Index"));
            }

            ModelState.AddModelError("", "Your message could not be updated.");
            return(View(model));
        }
Beispiel #3
0
        public ActionResult Edit(int?id)
        {
            // Получаем записи сообщения и текущего пользователя из БД
            Message msg  = db.Messages.Include("Topic").FirstOrDefault(p => p.Id == id);
            User    user = db.Users.FirstOrDefault(p => p.Login == User.Identity.Name);

            // Если такие записи есть
            if (msg != null && user != null)
            {
                // Пользователь может редактировать только свои записи
                // Если это не запись пользователя, то выводим страницу с ошибкой
                if (user.RoleId == 3 && user.Id != msg.UserId)
                {
                    return(View("Error"));
                }
                // формируем набор данных для формы
                ViewBag.TopicName = msg.Topic.Name;
                MessageEdit model = new MessageEdit();
                model.Id       = msg.Id;
                model.Disabled = msg.Disabled;
                model.TopicId  = (int)msg.TopicId;
                model.Content  = msg.Content;
                // выводим форму
                return(View(model));
            }
            else
            {
                return(View("Error"));
            }
        }
        public ActionResult CompleteRequest(int id)
        {
            var userId      = Guid.Parse(User.Identity.GetUserId());
            var coopService = new CooperatorService(userId);

            ViewBag.cooperators = coopService.GetCooperators(userId).Where(e => e.ContactType == contact.Employee);

            var locService = new LocationService(userId);

            ViewBag.locations = locService.GetLocations(userId);

            var service = CreateMessageService();
            var detail  = service.GetMessageEditById(id, userId);
            var model   = new MessageEdit
            {
                MessageId        = detail.MessageId,
                LocationId       = detail.LocationId,
                LocationCode     = detail.LocationCode,
                Comment          = detail.Comment,
                CooperatorId     = detail.CooperatorId,
                DateCreated      = detail.DateCreated,
                OwnerId          = detail.OwnerId,
                JobOne           = detail.JobOne,
                JobTwo           = detail.JobTwo,
                JobThree         = detail.JobThree,
                IsRequest        = detail.IsRequest,
                HumanGrowthStage = detail.HumanGrowthStage,
                Rating           = detail.Rating
            };

            return(View(model));
        }
Beispiel #5
0
 public ActionResult Create(MessageEdit model)
 {
     if (ModelState.IsValid)
     {
         // Получаем записи темы и пользователя из БД
         Topic topic = db.Topics.FirstOrDefault(p => p.Id == model.TopicId);
         User  user  = db.Users.FirstOrDefault(p => p.Login == User.Identity.Name);
         // Если такие записи есть
         if (topic != null && user != null)
         {
             // сохраняем сообщение в БД
             Message msg = new Message();
             msg.Content  = model.Content;
             msg.Dates    = DateTime.Now;
             msg.Disabled = false;
             msg.Topic    = topic;
             msg.User     = user;
             db.Messages.Add(msg);
             db.SaveChanges();
             // редирект к списку сообщений
             return(RedirectToAction("List/" + model.TopicId));
         }
         else
         {
             ModelState.AddModelError("", "Ошибка при сохранении");
         }
     }
     return(View(model));
 }
        public ActionResult CompleteRequest(int id, MessageEdit model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            if (model.MessageId != id)
            {
                ModelState.AddModelError("", "Id Mismatch");
                return(View(model));
            }

            var userId  = Guid.Parse(User.Identity.GetUserId());
            var service = new MessageService(userId);

            if (service.UpdateMessage(model, userId))
            {
                service.SetIsRequestToNo(model.MessageId, model.LocationId, model.DateCreated, userId);
                return(RedirectToAction("Index"));
            }

            ModelState.AddModelError("", "Your message could not be updated.");
            return(View(model));
        }
Beispiel #7
0
        public Task <Message> Edit(MessageEdit edit)
        {
            if (this.Client == null || this.Editable == null || this.Editable == false)
            {
                return(null);
            }

            return(this.Client.toolbox.EditMessage(this.ChannelId, this.Id, edit));
        }
Beispiel #8
0
        //Update

        public bool UpdateMessage(MessageEdit message)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity = ctx.Messages.Single(h => h.MessageId == message.MessageId && h.OwnerId == _userId);

                entity.MessageId      = message.MessageId;
                entity.MessageContent = message.MessageContent;

                return(ctx.SaveChanges() == 1);
            }
        }
        public bool UpdateMessage(MessageEdit model, Guid userId)
        {
            var locationService = new LocationService();

            using (var ctx = new ApplicationDbContext())
            {
                var entity = ctx.Messages.Single(e => e.MessageId == model.MessageId && e.OwnerId == userId);

                entity.MessageId        = model.MessageId;
                entity.Comment          = model.Comment;
                entity.MessageId        = model.MessageId;
                entity.LocationId       = model.LocationId;
                entity.Comment          = model.Comment;
                entity.CooperatorId     = model.CooperatorId;
                entity.DateCreated      = model.DateCreated;
                entity.OwnerId          = model.OwnerId;
                entity.JobOne           = model.JobOne;
                entity.JobTwo           = model.JobTwo;
                entity.JobThree         = model.JobThree;
                entity.HumanGrowthStage = model.HumanGrowthStage;
                entity.Rating           = model.Rating;
                entity.IsRequest        = model.IsRequest;

                if (model.Rating != rating.NoRating)
                {
                    locationService.SetLocationRating(model.LocationId, model.Rating);
                }

                if (model.JobOne == job.Planting || model.JobTwo == job.Planting || model.JobThree == job.Planting)
                {
                    locationService.EditLocationIsPlantedToYes(model.LocationId, entity.DateCreated);
                }

                if (model.JobOne == job.Staking || model.JobTwo == job.Staking || model.JobThree == job.Staking)
                {
                    locationService.SetLocationIsStakedToYes(model.LocationId);
                }

                if (model.JobOne == job.Rowbanding || model.JobTwo == job.Rowbanding || model.JobThree == job.Rowbanding)
                {
                    locationService.SetLocationIsRowbandedToYes(model.LocationId);
                }

                if (model.JobOne == job.Harvesting || model.JobTwo == job.Harvesting || model.JobThree == job.Harvesting)
                {
                    locationService.EditLocationIsHarvestedToYes(model.LocationId, entity.DateCreated);
                }

                locationService.SetLastVisitor(model.LocationId, entity.FullName);

                return(ctx.SaveChanges() == 1);
            }
        }
Beispiel #10
0
        public ActionResult Edit(int id)
        {
            var detail = _messageService.Value.GetMessageById(id);
            var model  =
                new MessageEdit
            {
                MessageId = detail.MessageId,
                Title     = detail.Title,
                Content   = detail.Content
            };

            return(View(model));
        }
        public bool UpdateMessage(MessageEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity =
                    ctx
                    .Messages
                    .Single(e => e.MessageId == model.MessageId && e.MessageOwnerId == _messageUserId);

                entity.MessageId  = model.MessageId;
                entity.NewMessage = model.NewMessage;

                return(ctx.SaveChanges() == 1);
            }
        }
Beispiel #12
0
 private void HelpCenterFormCaption_TouchUpInside(object sender, EventArgs e)
 {
     if (MessageContainer.Frame.Height == 0)
     {
         c.ExpandY(MessageContainer);
         c.CollapseY(QuestionsScroll);
         MessageEdit.BecomeFirstResponder();
     }
     else
     {
         c.CollapseY(MessageContainer);
         c.ExpandY(QuestionsScroll);
         View.EndEditing(true);
     }
 }
Beispiel #13
0
        // GET:
        public ActionResult Edit(int id)
        {
            var service = CreateMessageService();
            var detail  = service.GetMessageById(id);
            var model   =
                new MessageEdit
            {
                MessageId   = detail.MessageId,
                Subject     = detail.Subject,
                Content     = detail.Content,
                DateCreated = detail.DateCreated,
                //ModifiedDateCreated = detail.ModifiedDateCreated
            };

            return(View(model));
        }
Beispiel #14
0
        public bool Like(int id)
        {
            var service = CreateMessageService();

            var detail = service.GetMessageById(id);

            var updatedMessage =
                new MessageEdit
            {
                MessageId = detail.MessageId,
                Content   = detail.Content,
                IsLiked   = detail.IsLiked
            };

            return(service.UpdateMessage(updatedMessage));
        }
        public bool UpdateMessage(MessageEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity =
                    ctx
                    .Messages
                    .Single(e => e.MessageId == model.MessageId && e.OwnerId == _userId);

                entity.Title       = model.Title;
                entity.Content     = model.Content;
                entity.ModifiedUtc = DateTimeOffset.UtcNow;

                return(ctx.SaveChanges() == 1);
            }
        }
Beispiel #16
0
        public IHttpActionResult Put(MessageEdit message)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var service = CreateMessageService();

            if (!service.UpdateMessage(message))
            {
                return(InternalServerError());
            }

            return(Ok());
        }
Beispiel #17
0
        public bool UpdateMessage(MessageEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity =
                    ctx
                    .Messages
                    .Single(e => e.MessageId == model.MessageId && e.CreatorId == _userId);

                entity.Content     = model.Content;
                entity.Subject     = model.Subject;
                entity.DateCreated = model.DateCreated;
                // entity.ModifiedDateCreated = model.ModifiedDateCreated;

                return(ctx.SaveChanges() == 1);
            }
        }
        private void SettingsFormCaption_TouchUpInside(object sender, EventArgs e)
        {
            if (MessageContainer.Frame.Height == 0)
            {
                c.ExpandY(MessageContainer);
                UIView.Animate(Constants.tweenTime, () => { View.LayoutIfNeeded(); }, () => { });

                //page will scroll to bottom automatically as the TextView gets focus
                MessageEdit.BecomeFirstResponder();
            }
            else
            {
                c.CollapseY(MessageContainer);
                UIView.Animate(Constants.tweenTime, () => { View.LayoutIfNeeded(); }, () => { });
                View.EndEditing(true);
            }
        }
Beispiel #19
0
        public IHttpActionResult Put(MessageEdit model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            //Make sure the message exists
            var messageService = new MessageService(Guid.Parse(User.Identity.GetUserId()));
            var temp           = messageService.GetMessageById(model.MessageId);

            if (temp == null)
            {
                return(NotFound());
            }

            //Attempt to update
            return(Ok(messageService.UpdateMessage(model)));
        }
Beispiel #20
0
 public ActionResult Edit(MessageEdit model)
 {
     if (ModelState.IsValid)
     {
         Message msg = db.Messages.FirstOrDefault(p => p.Id == model.Id);
         if (msg != null)
         {
             msg.Content         = model.Content;
             msg.Disabled        = model.Disabled;
             db.Entry(msg).State = EntityState.Modified;
             db.SaveChanges();
             return(RedirectToAction("List/" + model.TopicId));
         }
         else
         {
             ModelState.AddModelError("", "Ошибка при сохранении");
         }
     }
     return(View(model));
 }
Beispiel #21
0
        public ActionResult Edit(int id, MessageEdit model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            if (model.MessageId != id)
            {
                ModelState.AddModelError("", "ID Does Not Match");
                return(View(model));
            }

            if (_messageService.Value.UpdateMessage(model))
            {
                TempData["SaveResult"] = "Your Message Was Updated";
                return(RedirectToAction("Index"));
            }

            ModelState.AddModelError("", "Your Message Could Not Be Updated");
            return(View(model));
        }
Beispiel #22
0
        public ActionResult Create(int id)
        {
            // Получаем запись темы из БД
            Topic topic = db.Topics.FirstOrDefault(p => p.Id == id);

            // Если такая запись есть
            if (topic != null)
            {
                // формируем набор данных для формы
                ViewBag.TopicName = topic.Name;
                MessageEdit model = new MessageEdit();
                model.Id       = -1;
                model.Disabled = false;
                model.TopicId  = id;
                // выводим форму
                return(View(model));
            }
            // иначе выводим страницу с ошибкой
            else
            {
                return(View("Error"));
            }
        }
Beispiel #23
0
        public ActionResult Delete(int?id)
        {
            Message msg  = db.Messages.Include("Topic").FirstOrDefault(p => p.Id == id);
            User    user = db.Users.FirstOrDefault(p => p.Login == User.Identity.Name);

            if (msg != null && user != null)
            {
                if (user.RoleId == 3 && user.Id != msg.UserId)
                {
                    return(View("Error"));
                }
                ViewBag.TopicName = msg.Topic.Name;
                MessageEdit model = new MessageEdit();
                model.Id       = msg.Id;
                model.Disabled = msg.Disabled;
                model.TopicId  = (int)msg.TopicId;
                model.Content  = msg.Content;
                return(View(model));
            }
            else
            {
                return(View("Error"));
            }
        }
        void ReleaseDesignerOutlets()
        {
            if (BottomConstraint != null)
            {
                BottomConstraint.Dispose();
                BottomConstraint = null;
            }

            if (CheckMatchBackground != null)
            {
                CheckMatchBackground.Dispose();
                CheckMatchBackground = null;
            }

            if (CheckMatchInApp != null)
            {
                CheckMatchInApp.Dispose();
                CheckMatchInApp = null;
            }

            if (CheckMessageBackground != null)
            {
                CheckMessageBackground.Dispose();
                CheckMessageBackground = null;
            }

            if (CheckMessageInApp != null)
            {
                CheckMessageInApp.Dispose();
                CheckMessageInApp = null;
            }

            if (CheckRematchBackground != null)
            {
                CheckRematchBackground.Dispose();
                CheckRematchBackground = null;
            }

            if (CheckRematchInApp != null)
            {
                CheckRematchInApp.Dispose();
                CheckRematchInApp = null;
            }

            if (CheckUnmatchBackground != null)
            {
                CheckUnmatchBackground.Dispose();
                CheckUnmatchBackground = null;
            }

            if (CheckUnmatchInApp != null)
            {
                CheckUnmatchInApp.Dispose();
                CheckUnmatchInApp = null;
            }

            if (DisplaySection != null)
            {
                DisplaySection.Dispose();
                DisplaySection = null;
            }

            if (InAppLocationRate != null)
            {
                InAppLocationRate.Dispose();
                InAppLocationRate = null;
            }

            if (InAppLocationRateExplanation != null)
            {
                InAppLocationRateExplanation.Dispose();
                InAppLocationRateExplanation = null;
            }

            if (InAppLocationRateLabel != null)
            {
                InAppLocationRateLabel.Dispose();
                InAppLocationRateLabel = null;
            }

            if (InAppLocationRateLabelConstraint != null)
            {
                InAppLocationRateLabelConstraint.Dispose();
                InAppLocationRateLabelConstraint = null;
            }

            if (InAppLocationRateValue != null)
            {
                InAppLocationRateValue.Dispose();
                InAppLocationRateValue = null;
            }

            if (LocationHistoryButton != null)
            {
                LocationHistoryButton.Dispose();
                LocationHistoryButton = null;
            }

            if (LocationHistoryButtonConstraint != null)
            {
                LocationHistoryButtonConstraint.Dispose();
                LocationHistoryButtonConstraint = null;
            }

            if (LocationLabel != null)
            {
                LocationLabel.Dispose();
                LocationLabel = null;
            }

            if (MapIconSize != null)
            {
                MapIconSize.Dispose();
                MapIconSize = null;
            }

            if (MapIconSizeLabel != null)
            {
                MapIconSizeLabel.Dispose();
                MapIconSizeLabel = null;
            }

            if (MapIconSizeValue != null)
            {
                MapIconSizeValue.Dispose();
                MapIconSizeValue = null;
            }

            if (MapRatio != null)
            {
                MapRatio.Dispose();
                MapRatio = null;
            }

            if (MapRatioLabel != null)
            {
                MapRatioLabel.Dispose();
                MapRatioLabel = null;
            }

            if (MapRatioValue != null)
            {
                MapRatioValue.Dispose();
                MapRatioValue = null;
            }

            if (MessageContainer != null)
            {
                MessageContainer.Dispose();
                MessageContainer = null;
            }

            if (MessageEdit != null)
            {
                MessageEdit.Dispose();
                MessageEdit = null;
            }

            if (MessageSend != null)
            {
                MessageSend.Dispose();
                MessageSend = null;
            }

            if (NotificationsBackground != null)
            {
                NotificationsBackground.Dispose();
                NotificationsBackground = null;
            }

            if (NotificationsInApp != null)
            {
                NotificationsInApp.Dispose();
                NotificationsInApp = null;
            }

            if (NotificationsLabel != null)
            {
                NotificationsLabel.Dispose();
                NotificationsLabel = null;
            }

            if (NotificationsNewMatchLabel != null)
            {
                NotificationsNewMatchLabel.Dispose();
                NotificationsNewMatchLabel = null;
            }

            if (NotificationsNewMessageLabel != null)
            {
                NotificationsNewMessageLabel.Dispose();
                NotificationsNewMessageLabel = null;
            }

            if (NotificationsRematchLabel != null)
            {
                NotificationsRematchLabel.Dispose();
                NotificationsRematchLabel = null;
            }

            if (NotificationsUnmatchLabel != null)
            {
                NotificationsUnmatchLabel.Dispose();
                NotificationsUnmatchLabel = null;
            }

            if (ProgramLogButton != null)
            {
                ProgramLogButton.Dispose();
                ProgramLogButton = null;
            }

            if (ProgramLogIncluded != null)
            {
                ProgramLogIncluded.Dispose();
                ProgramLogIncluded = null;
            }

            if (RippleSettings != null)
            {
                RippleSettings.Dispose();
                RippleSettings = null;
            }

            if (RoundBottom != null)
            {
                RoundBottom.Dispose();
                RoundBottom = null;
            }

            if (ScrollBottomConstraint != null)
            {
                ScrollBottomConstraint.Dispose();
                ScrollBottomConstraint = null;
            }

            if (ScrollBottomOuterConstraint != null)
            {
                ScrollBottomOuterConstraint.Dispose();
                ScrollBottomOuterConstraint = null;
            }

            if (Settings_Scroll != null)
            {
                Settings_Scroll.Dispose();
                Settings_Scroll = null;
            }

            if (SettingsBack != null)
            {
                SettingsBack.Dispose();
                SettingsBack = null;
            }

            if (SettingsFormCaption != null)
            {
                SettingsFormCaption.Dispose();
                SettingsFormCaption = null;
            }

            if (SettingsHeaderText != null)
            {
                SettingsHeaderText.Dispose();
                SettingsHeaderText = null;
            }

            if (Snackbar != null)
            {
                Snackbar.Dispose();
                Snackbar = null;
            }

            if (SnackBottomConstraint != null)
            {
                SnackBottomConstraint.Dispose();
                SnackBottomConstraint = null;
            }

            if (SnackTopConstraint != null)
            {
                SnackTopConstraint.Dispose();
                SnackTopConstraint = null;
            }
        }
 public bool UpdateMessage(MessageEdit model)
 {
     throw new NotImplementedException();
 }
Beispiel #26
0
        void ReleaseDesignerOutlets()
        {
            if (BottomConstraint != null)
            {
                BottomConstraint.Dispose();
                BottomConstraint = null;
            }

            if (HelpCenterBack != null)
            {
                HelpCenterBack.Dispose();
                HelpCenterBack = null;
            }

            if (HelpCenterFormCaption != null)
            {
                HelpCenterFormCaption.Dispose();
                HelpCenterFormCaption = null;
            }

            if (HelpCenterHeaderText != null)
            {
                HelpCenterHeaderText.Dispose();
                HelpCenterHeaderText = null;
            }

            if (LoaderCircle != null)
            {
                LoaderCircle.Dispose();
                LoaderCircle = null;
            }

            if (MessageContainer != null)
            {
                MessageContainer.Dispose();
                MessageContainer = null;
            }

            if (MessageEdit != null)
            {
                MessageEdit.Dispose();
                MessageEdit = null;
            }

            if (MessageSend != null)
            {
                MessageSend.Dispose();
                MessageSend = null;
            }

            if (OpenTutorial != null)
            {
                OpenTutorial.Dispose();
                OpenTutorial = null;
            }

            if (QuestionsScroll != null)
            {
                QuestionsScroll.Dispose();
                QuestionsScroll = null;
            }

            if (RippleHelpCenter != null)
            {
                RippleHelpCenter.Dispose();
                RippleHelpCenter = null;
            }

            if (RippleTutorial1 != null)
            {
                RippleTutorial1.Dispose();
                RippleTutorial1 = null;
            }

            if (RippleTutorial2 != null)
            {
                RippleTutorial2.Dispose();
                RippleTutorial2 = null;
            }

            if (RoundBottom != null)
            {
                RoundBottom.Dispose();
                RoundBottom = null;
            }

            if (RoundBottomTutorial != null)
            {
                RoundBottomTutorial.Dispose();
                RoundBottomTutorial = null;
            }

            if (Snackbar != null)
            {
                Snackbar.Dispose();
                Snackbar = null;
            }

            if (SnackBottomConstraint != null)
            {
                SnackBottomConstraint.Dispose();
                SnackBottomConstraint = null;
            }

            if (SnackTopConstraint != null)
            {
                SnackTopConstraint.Dispose();
                SnackTopConstraint = null;
            }

            if (TutorialBack != null)
            {
                TutorialBack.Dispose();
                TutorialBack = null;
            }

            if (TutorialBottomSeparator != null)
            {
                TutorialBottomSeparator.Dispose();
                TutorialBottomSeparator = null;
            }

            if (TutorialFrame != null)
            {
                TutorialFrame.Dispose();
                TutorialFrame = null;
            }

            if (TutorialFrameBg != null)
            {
                TutorialFrameBg.Dispose();
                TutorialFrameBg = null;
            }

            if (TutorialLoadNext != null)
            {
                TutorialLoadNext.Dispose();
                TutorialLoadNext = null;
            }

            if (TutorialLoadPrevious != null)
            {
                TutorialLoadPrevious.Dispose();
                TutorialLoadPrevious = null;
            }

            if (TutorialNavBar != null)
            {
                TutorialNavBar.Dispose();
                TutorialNavBar = null;
            }

            if (TutorialNavText != null)
            {
                TutorialNavText.Dispose();
                TutorialNavText = null;
            }

            if (TutorialText != null)
            {
                TutorialText.Dispose();
                TutorialText = null;
            }

            if (TutorialTopBar != null)
            {
                TutorialTopBar.Dispose();
                TutorialTopBar = null;
            }

            if (TutorialTopSeparator != null)
            {
                TutorialTopSeparator.Dispose();
                TutorialTopSeparator = null;
            }
        }