Example #1
0
        public ActionResult Attend(Peanut peanut, User currentUser, PeanutParticipationCreateCommand peanutParticipationCreateCommand)
        {
            Require.NotNull(peanut, "peanut");
            Require.NotNull(currentUser, "currentUser");
            Require.IsFalse(() => peanut.IsFixed, "peanut");

            UserGroupMembership userGroupMembership = UserGroupService.FindMembershipsByUserAndGroup(currentUser, peanut.UserGroup);

            Require.NotNull(userGroupMembership, "userGroupMembership");


            if (!UserGroupService.IsUserSolvent(userGroupMembership))
            {
                return(View("CanNotParticipate",
                            new PeanutParticipationRejectedViewModel(peanut)));
            }

            if (!ModelState.IsValid)
            {
                IList <PeanutParticipationType> peanutParticipationTypes = PeanutParticipationTypeService.Find(peanut.UserGroup);
                return(View("CreateParticipation",
                            new PeanutParticipationCreateFormViewModel(peanut, peanutParticipationTypes.ToList(), peanutParticipationCreateCommand)));
            }

            PeanutService.AddOrUpdateParticipations(peanut,
                                                    new Dictionary <UserGroupMembership, PeanutParticipationDto> {
                {
                    userGroupMembership,
                    new PeanutParticipationDto(peanutParticipationCreateCommand.PeanutParticipationType, PeanutParticipationState.Confirmed)
                }
            },
                                                    currentUser);

            return(RedirectToAction("Show", new { peanut = peanut.BusinessId }));
        }
Example #2
0
 /// <summary>
 ///     Rechnet den Peanut ab und speichert die Rechnung an diesem
 /// </summary>
 /// <param name="peanut">Der Peanut der abgerechnet wird</param>
 /// <param name="bill">Die Rechnung zum Peanut</param>
 /// <returns></returns>
 public Peanut ClearPeanut(Peanut peanut, Bill bill)
 {
     Require.NotNull(peanut, "peanut");
     Require.NotNull(bill, "bill");
     peanut.Clear(bill);
     return(peanut);
 }
Example #3
0
        public ActionResult Show(Peanut peanut, User currentUser)
        {
            Require.NotNull(peanut, "peanut");
            Require.NotNull(currentUser, "currentUser");

            IList <PeanutParticipationType> peanutParticipationTypes = PeanutParticipationTypeService.Find(peanut.UserGroup);
            List <UserGroupMembership>      userGroupMemberships     =
                UserGroupService.FindMembershipsByGroups(PageRequest.All,
                                                         new List <UserGroup> {
                peanut.UserGroup
            },
                                                         UserGroupMembership.ActiveTypes).ToList();
            /*Es können alle Nutzer eingeladen werden, die in der Gruppe aktives Mitglied sind und noch nicht am Peanut teilnehmen oder ihre Teilnahme abgesagt haben*/
            List <UserGroupMembership> invitableUsers =
                userGroupMemberships.Except(
                    peanut.Participations.Where(part => part.ParticipationState != PeanutParticipationState.Refused)
                    .Select(part => part.UserGroupMembership)).ToList();

            return(View("Show",
                        new PeanutShowViewModel(peanut,
                                                peanut.Participations.SingleOrDefault(part => part.UserGroupMembership.User.Equals(currentUser)),
                                                invitableUsers,
                                                peanutParticipationTypes,
                                                new PeanutEditOptions(peanut, currentUser))));
        }
Example #4
0
        public ActionResult CreateFromPeanut(Peanut peanut, User currentUser)
        {
            Require.NotNull(currentUser, "currentUser");
            Require.NotNull(peanut, "peanut");

            UserGroupMembership         currentUsersMembershipsInPeanutGroup = UserGroupService.FindMembershipsByUserAndGroup(currentUser, peanut.UserGroup);
            IList <UserGroupMembership> availableUserGroupMemberships        =
                UserGroupService.FindMembershipsByGroups(PageRequest.All,
                                                         new List <UserGroup> {
                peanut.UserGroup
            },
                                                         UserGroupMembership.ActiveTypes).ToList();
            BillCreateViewModel billCreateViewModel = new BillCreateViewModel(new List <UserGroupMembership> {
                currentUsersMembershipsInPeanutGroup
            },
                                                                              availableUserGroupMemberships,
                                                                              peanut);

            billCreateViewModel.BillCreateCommand.UserGroup       = peanut.UserGroup;
            billCreateViewModel.BillCreateCommand.BillDto.Subject = peanut.Name;
            IEnumerable <PeanutParticipation> participations =
                peanut.Participations.Where(s => s.ParticipationState == PeanutParticipationState.Confirmed);

            IDictionary <string, BillUserGroupDebitorDto> userGroupDebitors = new Dictionary <string, BillUserGroupDebitorDto>();

            foreach (PeanutParticipation peanutParticipation in participations)
            {
                UserGroupMembership membership = peanutParticipation.UserGroupMembership;
                userGroupDebitors.Add(membership.BusinessId.ToString(), new BillUserGroupDebitorDto(membership, 1));
            }

            billCreateViewModel.BillCreateCommand.UserGroupDebitors = userGroupDebitors;

            return(View("Create", billCreateViewModel));
        }
Example #5
0
        public ActionResult UpdateParticipation(Peanut peanut, PeanutParticipation peanutParticipation,
                                                PeanutParticipationUpdateCommand peanutParticipationUpdateCommand, User currentUser)
        {
            Require.NotNull(peanut, "peanut");
            Require.NotNull(peanutParticipation, "peanutParticipation");
            Require.NotNull(peanutParticipationUpdateCommand, "peanutParticipationUpdateCommand");
            Require.IsTrue(() => peanut.Equals(peanutParticipation.Peanut), "peanutParticipation");

            if (!ModelState.IsValid)
            {
                return(RedirectToAction("Show", new { peanut = peanut.BusinessId }));
            }

            Dictionary <UserGroupMembership, PeanutParticipationDto> participationUpdates =
                new Dictionary <UserGroupMembership, PeanutParticipationDto> {
                {
                    peanutParticipation.UserGroupMembership,
                    new PeanutParticipationDto(peanutParticipationUpdateCommand.PeanutParticipationType,
                                               peanutParticipation.ParticipationState)
                }
            };

            PeanutService.AddOrUpdateParticipations(peanut,
                                                    participationUpdates,
                                                    currentUser);

            return(RedirectToAction("Show", new { peanut = peanut.BusinessId }));
        }
Example #6
0
 public void Chop(Mobile from)
 {
     if (from.InRange(this.GetWorldLocation(), 1))
     {
         if (from == m_sower)
         {
             from.Direction = from.GetDirectionTo(this);
             double lumberValue = from.Skills[SkillName.Lumberjacking].Value / 100;
             if ((lumberValue > .5) && (Utility.RandomDouble() <= lumberValue))
             {
                 Peanut fruit = new Peanut(Utility.Random(m_yield + 2));
                 from.AddToBackpack(fruit);
             }
             this.Delete();
             from.SendMessage("You chop the plant up");
         }
         else
         {
             from.SendMessage("You do not own this plant !!!");
         }
     }
     else
     {
         from.SendLocalizedMessage(500446);
     }
 }
Example #7
0
        public void SendPeanutUpdateRequirementsNotification(Peanut peanut, string updateComment,
                                                             PeanutUpdateRequirementsNotificationOptions notificationOptions, User user)
        {
            Require.NotNull(peanut, "peanut");
            Require.NotNull(notificationOptions, "notificationOptions");
            Require.NotNull(user, "user");
            if (string.IsNullOrWhiteSpace(updateComment))
            {
                updateComment = "-";
            }

            foreach (PeanutParticipation creditors in FindCreditorsToNotifyOnRequirementsChange(peanut, user))
            {
                ModelMap modelMap = new ModelMap();
                modelMap.Add("peanut", peanut);
                modelMap.Add("editor", user);
                modelMap.Add("recipient", creditors.UserGroupMembership.User);
                modelMap.Add("peanutUrl", notificationOptions.PeanutUrl);
                modelMap.Add("requirements",
                             string.Join(Environment.NewLine, peanut.Requirements.Select(r => string.Format("<li>{0} {1}</li>", r.QuantityAndUnit, r.Name))));
                modelMap.Add("updateComment", updateComment);

                MailMessage mailMessage = EmailService.CreateMailMessage(creditors.UserGroupMembership.User.Email,
                                                                         modelMap,
                                                                         "PeanutRequirementsUpdated");
                EmailService.SendMessage(mailMessage);
            }
        }
Example #8
0
        public ActionResult InviteUser(Peanut peanut, PeanutInvitationCreateCommand peanutInvitationCreateCommand, User currentUser)
        {
            Require.NotNull(peanut, "peanut");
            Require.NotNull(peanutInvitationCreateCommand, "peanutInvitationCreateCommand");
            Require.NotNull(currentUser, "currentUser");

            if (peanut.IsFixed)
            {
                return(View("CanNotInvite", new PeanutParticipationRejectedViewModel(peanut)));
            }

            string peanutUrl       = Url.Action("Show", "Peanut", new { peanut = peanut.BusinessId }, Request.Url.Scheme);
            string attendPeanutUrl = Url.Action("AttendForm", "Peanut", new { peanut = peanut.BusinessId }, Request.Url.Scheme);

            if (peanutInvitationCreateCommand.UserGroupMembership != null)
            {
                PeanutService.InviteUser(peanut,
                                         peanutInvitationCreateCommand.UserGroupMembership,
                                         new PeanutParticipationDto(peanutInvitationCreateCommand.PeanutParticipationType, PeanutParticipationState.Pending),
                                         new PeanutInvitationNotificationOptions(peanutUrl, attendPeanutUrl),
                                         currentUser);
            }
            else
            {
                PeanutService.InviteAllGroupMembers(peanut,
                                                    peanut.UserGroup,
                                                    peanutInvitationCreateCommand.PeanutParticipationType,
                                                    new PeanutInvitationNotificationOptions(peanutUrl, attendPeanutUrl),
                                                    currentUser);
            }

            return(RedirectToAction("Show", new { peanut = peanut.BusinessId }));
        }
Example #9
0
        public void SendPeanutUpdateStateNotification(Peanut peanut, PeanutUpdateNotificationOptions notificationOptions, User user)
        {
            Require.NotNull(peanut, "peanut");
            Require.NotNull(notificationOptions, "notificationOptions");

            if (peanut.PeanutState == PeanutState.Started)
            {
                /*Der Peanut wurde gestartet => alle Teilnehmer, außer den ändernden Nutzer benachrichtigen*/
                foreach (PeanutParticipation peanutParticipation in FindParticipatorsToNotifyOnUpdate(peanut, user))
                {
                    ModelMap modelMap = new ModelMap();
                    modelMap.Add("peanut", peanut);
                    modelMap.Add("editor", user);
                    modelMap.Add("recipient", peanutParticipation.UserGroupMembership.User);
                    modelMap.Add("participation", peanutParticipation);
                    modelMap.Add("peanutUrl", notificationOptions.PeanutUrl);
                    MailMessage mailMessage = EmailService.CreateMailMessage(peanutParticipation.UserGroupMembership.User.Email,
                                                                             modelMap,
                                                                             "PeanutStart");
                    EmailService.SendMessage(mailMessage);
                }
            }

            if (peanut.PeanutState == PeanutState.PurchasingDone)
            {
                /*Der Beschaffung der Voraussetzungen für den Peanut ist abgeschlossen => alle Produzenten, außer den ändernden Nutzer, benachrichtigen*/
                foreach (PeanutParticipation peanutParticipation in FindProducersToNotifyOnPurchasingDone(peanut, user))
                {
                    ModelMap modelMap = new ModelMap();
                    modelMap.Add("peanut", peanut);
                    modelMap.Add("editor", user);
                    modelMap.Add("recipient", peanutParticipation.UserGroupMembership.User);
                    modelMap.Add("participation", peanutParticipation);
                    modelMap.Add("peanutUrl", notificationOptions.PeanutUrl);
                    MailMessage mailMessage = EmailService.CreateMailMessage(peanutParticipation.UserGroupMembership.User.Email,
                                                                             modelMap,
                                                                             "PeanutPurchasingDone");
                    EmailService.SendMessage(mailMessage);
                }
            }

            if (peanut.PeanutState == PeanutState.Canceled)
            {
                /*Der Peanut wurde abgesagt => alle Teilnehmer, außer den ändernden Nutzer benachrichtigen*/
                foreach (PeanutParticipation peanutParticipation in FindParticipatorsToNotifyOnUpdate(peanut, user))
                {
                    ModelMap modelMap = new ModelMap();
                    modelMap.Add("peanut", peanut);
                    modelMap.Add("editor", user);
                    modelMap.Add("recipient", peanutParticipation.UserGroupMembership.User);
                    modelMap.Add("participation", peanutParticipation);
                    modelMap.Add("peanutUrl", notificationOptions.PeanutUrl);
                    MailMessage mailMessage = EmailService.CreateMailMessage(peanutParticipation.UserGroupMembership.User.Email,
                                                                             modelMap,
                                                                             "PeanutCanceled");
                    EmailService.SendMessage(mailMessage);
                }
            }
        }
Example #10
0
        public ActionResult Show(Bill bill, User currentUser)
        {
            Require.NotNull(bill, "bill");
            Require.NotNull(currentUser, "currentUser");

            Peanut createdFromPeanut = PeanutService.FindFromBill(bill);

            return(View("Show", new BillShowViewModel(bill, new BillOptions(bill, currentUser), createdFromPeanut)));
        }
Example #11
0
            public object Execute(Peanut.RequestType type)
            {
                if (type == Peanut.RequestType.POST )
                {
                    Result = string.Format("value:{0}", Number);
                }

                return this;
            }
Example #12
0
        public ActionResult AttendForm(Peanut peanut, User currentUser)
        {
            Require.NotNull(peanut, "peanut");
            Require.NotNull(currentUser, "currentUser");
            Require.IsFalse(() => peanut.IsFixed, "peanut");

            IList <PeanutParticipationType> peanutParticipationTypes = PeanutParticipationTypeService.Find(peanut.UserGroup);

            return(View("CreateParticipation", new PeanutParticipationCreateFormViewModel(peanut, peanutParticipationTypes.ToList())));
        }
Example #13
0
 private IList <PeanutParticipation> FindProducersToNotifyOnPurchasingDone(Peanut peanut, User user)
 {
     return
         (peanut.ConfirmedParticipations.Where(
              part =>
              part.ParticipationType.IsProducer &&
              part.UserGroupMembership.User.NotifyMeAsParticipatorOnPeanutChanged &&
              !part.UserGroupMembership.User.Equals(user))
          .ToList());
 }
Example #14
0
 public object Execute(Peanut.RequestType type)
 {
     if (type == Peanut.RequestType.POST)
     {
         if (!string.IsNullOrEmpty(YouName))
         {
             Data = string.Format("holle {0} :) Peanut  is .net mvc framework!",YouName);
         }
     }
     return this;
 }
Example #15
0
 public object Execute(Peanut.RequestType type)
 {
     if (OutpuType == "xml")
     {
         return new Peanut.OutputObject(User, new Peanut.XMLContractAttribute());
     }
     else
     {
         return new Peanut.OutputObject(User, new Peanut.JSONContractAttribute());
     }
 }
Example #16
0
 public object Execute(Peanut.RequestType type)
 {
     Clay.Logic.Modules.Control control = Utils.ControlService.Load(PageName);
     if (control != null)
     {
         LoadChilds(control.Controls, Body);
     }
     Body.ID = PageName;
     Body.IsEdit = true;
     return this;
 }
Example #17
0
        public ActionResult DeclineParticipation(Peanut peanut, PeanutParticipation peanutParticipation, User currentUser)
        {
            Require.NotNull(peanut, "peanut");
            Require.NotNull(peanutParticipation, "peanutParticipation");
            Require.IsTrue(() => peanutParticipation.Peanut.Equals(peanut), "peanutParticipation");

            PeanutService.RemoveParticipations(peanut, new List <UserGroupMembership> {
                peanutParticipation.UserGroupMembership
            }, currentUser);

            return(RedirectToAction("Day", new { year = peanut.Day.Year, month = peanut.Day.Month, day = peanut.Day.Day }));
        }
Example #18
0
        public ActionResult UpdateState(Peanut peanut, PeanutState peanutState, User currentUser)
        {
            Require.NotNull(peanut, "peanut");
            Require.NotNull(currentUser, "currentUser");

            string peanutUrl = Url.Action("Show", "Peanut", new { peanut = peanut.BusinessId }, Request.Url.Scheme);
            PeanutUpdateNotificationOptions peanutUpdateNotificationOptions = new PeanutUpdateNotificationOptions(true, peanutUrl);

            PeanutService.UpdateState(peanut, peanutState, peanutUpdateNotificationOptions, currentUser);

            return(RedirectToAction("Show", new { peanut = peanut.BusinessId }));
        }
Example #19
0
        public override void Change(Peanut.Command cmd)
        {
            string sql =string.Format("select top {1} * from ({0}) ",cmd.Text.ToString(),Max);
#if NET_4
            cmd.Text.Clear();
#else
            cmd.Text.Remove(0, cmd.Text.Length);
#endif
           
            cmd.Text.Append(sql);
           
        }
Example #20
0
        /// <summary>
        ///     Sucht nach Teilnehmern an einem Peanut, die eine Benachrichtigung erhalten müssen, nachdem ein Peanut geändert
        ///     wurde.
        /// </summary>
        /// <param name="peanut"></param>
        /// <param name="editor"></param>
        /// <returns></returns>
        private IList <PeanutParticipation> FindParticipatorsToNotifyOnUpdate(Peanut peanut, User editor)
        {
            List <PeanutParticipation> participations = peanut.Participations.Where(part =>
                                                                                    /*Nur bestätigte Teilnahmen*/
                                                                                    part.ParticipationState == PeanutParticipationState.Confirmed &&
                                                                                    /*Der Bearbeiter braucht keine Benachrichtigung erhalten*/
                                                                                    !part.UserGroupMembership.User.Equals(editor) &&
                                                                                    /*Nur die Nutzer, die benachrichtigt werden wollen*/
                                                                                    part.UserGroupMembership.User.NotifyMeAsParticipatorOnPeanutChanged
                                                                                    ).ToList();

            return(participations);
        }
Example #21
0
        public void RemoveParticipations(Peanut peanut, IList <UserGroupMembership> participators, User user)
        {
            Require.NotNull(participators, "participators");
            Require.NotNull(peanut, "peanut");
            Require.NotNull(user, "user");

            if (peanut.IsFixed)
            {
                throw new InvalidOperationException("Die Teilnahme  an einem fixierten Peanut kann nicht abgesagt werden.");
            }

            peanut.RemoveParticipators(new EntityChangedDto(user, DateTime.Now), participators.ToArray());
        }
Example #22
0
        public void InviteUser(Peanut peanut, UserGroupMembership userGroupMembership, PeanutParticipationDto peanutParticipationDto,
                               PeanutInvitationNotificationOptions peanutInvitationNotificationOptions, User user)
        {
            /*Nutzer/Teilnahme hinzufügen*/
            AddOrUpdateParticipations(peanut,
                                      new Dictionary <UserGroupMembership, PeanutParticipationDto> {
                { userGroupMembership, peanutParticipationDto }
            },
                                      user);

            /*Den Nutzer benachrichtigen*/
            NotificationService.SendPeanutInvitationNotification(peanut, userGroupMembership.User, peanutInvitationNotificationOptions, user);
        }
Example #23
0
        public ActionResult AddComment(Peanut peanut, PeanutCommentCreateCommand peanutCommentCreateCommand, User currentUser)
        {
            if (!ModelState.IsValid)
            {
                return(RedirectToAction("Show", new { peanut = peanut.BusinessId }));
            }

            PeanutService.AddComment(peanut,
                                     peanutCommentCreateCommand.Comment,
                                     new PeanutUpdateNotificationOptions(peanutCommentCreateCommand.SendUpdateNotification,
                                                                         Url.Action("Show", "Peanut", new { peanut = peanut.BusinessId }, Request.Url.Scheme)),
                                     currentUser);
            return(RedirectToAction("Show", new { peanut = peanut.BusinessId }));
        }
Example #24
0
            public object Execute(Peanut.RequestType type)
            {
                AjaxStatus result = new AjaxStatus();
                try
                {
                    Utils.ControlService.AddModule(ParentID, ModuleName);

                }
                catch (Exception e)
                {
                    result.Error = e;
                }
                return result;
            }
Example #25
0
        public Peanut Create(UserGroup userGroup, PeanutDto peanutDto, IList <RequirementDto> requirements,
                             IDictionary <UserGroupMembership, PeanutParticipationDto> initialParticipators, User user)
        {
            foreach (UserGroupMembership groupMembership in initialParticipators.Keys)
            {
                if (!userGroup.Equals(groupMembership.UserGroup))
                {
                    throw new InvalidOperationException("Ein Peanut kann nur für Mitglieder der selben Gruppe erstellt werden.");
                }
            }
            Peanut peanut = new Peanut(userGroup, peanutDto, requirements, initialParticipators, new EntityCreatedDto(user, DateTime.Now));

            PeanutDao.Save(peanut);
            return(peanut);
        }
Example #26
0
 public void SendPeanutCommentNotification(Peanut peanut, string comment, PeanutUpdateNotificationOptions notificationOptions, User user)
 {
     Require.NotNull(peanut, "peanut");
     foreach (PeanutParticipation peanutParticipation in FindParticipatorsToNotifyOnUpdate(peanut, user))
     {
         ModelMap modelMap = new ModelMap();
         modelMap.Add("peanut", peanut);
         modelMap.Add("user", user);
         modelMap.Add("recipient", peanutParticipation.UserGroupMembership.User);
         modelMap.Add("peanutUrl", notificationOptions.PeanutUrl);
         modelMap.Add("comment", comment);
         MailMessage mailMessage = EmailService.CreateMailMessage(peanutParticipation.UserGroupMembership.User.Email, modelMap, "PeanutComment");
         EmailService.SendMessage(mailMessage);
     }
 }
Example #27
0
        public void Delete(Bill bill)
        {
            Require.NotNull(bill, "bill");

            if (bill.IsSettled)
            {
                throw new InvalidOperationException("Eine abgerechnete Rechnung darf nicht gelöscht werden!");
            }
            Peanut billForPeanut = PeanutService.FindFromBill(bill);

            if (billForPeanut != null)
            {
                billForPeanut.RemoveAssociatedBill(bill);
            }
            BillDao.Delete(bill);
        }
Example #28
0
 public object Execute(Peanut.RequestType type)
 {
     string PageName  =  Peanut.WebContext.Current.Request.FilePath;
     Clay.Logic.Modules.Control control = Utils.ControlService.Load(PageName);
     if (control != null)
     {
         LoadChilds(control.Controls, Body);
     }
     else
     {
         Peanut.WebContext.Current.Response.Redirect("LayoutEditor/PageEditor.aspx?PageName=" +PageName);
     }
     Body.ID = PageName;
     Body.IsEdit = true;
     return this;
 }
Example #29
0
        public void AddComment(Peanut peanut, string updateComment, PeanutUpdateNotificationOptions notificationOptions, User user)
        {
            Require.NotNull(peanut, "peanut");
            Require.NotNull(user, "user");
            Require.NotNull(notificationOptions, "notificationOptions");
            Require.NotNullOrWhiteSpace(updateComment, "updateComment");

            if (!string.IsNullOrWhiteSpace(updateComment))
            {
                /*Wenn es einen Änderungskommentar gibt, dann diesen hinzufügen.*/
                peanut.AddComment(updateComment, new EntityCreatedDto(user, DateTime.Now));
            }
            if (notificationOptions.SendNotification)
            {
                NotificationService.SendPeanutCommentNotification(peanut, updateComment, notificationOptions, user);
            }
        }
Example #30
0
        public void Update(Peanut peanut, PeanutDto peanutDto, IList <RequirementDto> requirements, string updateComment,
                           PeanutUpdateNotificationOptions notificationOptions, User user)
        {
            Require.NotNull(peanut, "peanut");
            Require.NotNull(peanutDto, "peanutDto");
            Require.NotNull(requirements, "requirements");
            Require.NotNull(user, "user");
            Require.NotNull(notificationOptions, "notificationOptions");

            PeanutDto dtoBeforeUpdate = peanut.GetDto();
            IList <PeanutRequirement> requirementsBeforeUpdate = peanut.Requirements;

            if (HasPeanutChanged(peanut, peanutDto, requirements))
            {
                /*Es wurden Änderungen am Peanut vorgenommen!*/
                peanut.Update(peanutDto, requirements, new EntityChangedDto(user, DateTime.Now));
                if (!string.IsNullOrWhiteSpace(updateComment))
                {
                    /*Wenn es einen Änderungskommentar gibt, dann diesen hinzufügen.*/
                    peanut.AddComment(updateComment, new EntityCreatedDto(user, DateTime.Now));
                }

                if (notificationOptions.SendNotification)
                {
                    NotificationService.SendPeanutUpdateNotification(peanut,
                                                                     dtoBeforeUpdate,
                                                                     requirementsBeforeUpdate,
                                                                     updateComment,
                                                                     notificationOptions,
                                                                     user);
                }
                if (HaveRequirementsChanged(requirementsBeforeUpdate, requirements))
                {
                    NotificationService.SendPeanutUpdateRequirementsNotification(peanut,
                                                                                 updateComment,
                                                                                 new PeanutUpdateRequirementsNotificationOptions(notificationOptions.PeanutUrl),
                                                                                 user);
                }
            }
            else if (!string.IsNullOrWhiteSpace(updateComment))
            {
                /*Es wurde nur ein Kommentar hinterlassen*/
                AddComment(peanut, updateComment, notificationOptions, user);
            }
        }
Example #31
0
        public void SendPeanutInvitationNotification(Peanut peanut, User notifiedUser, PeanutInvitationNotificationOptions notificationOptions, User user)
        {
            Require.NotNull(notificationOptions, "notificationOptions");
            Require.NotNull(user, "user");

            if (notifiedUser.NotifyMeOnPeanutInvitation)
            {
                ModelMap modelMap = new ModelMap();
                modelMap.Add("peanut", peanut);
                modelMap.Add("user", user);
                modelMap.Add("recipient", notifiedUser);
                modelMap.Add("peanutUrl", notificationOptions.PeanutUrl);
                modelMap.Add("attendPeanutUrl", notificationOptions.AttendPeanutUrl);
                MailMessage mailMessage = EmailService.CreateMailMessage(notifiedUser.Email, modelMap, "PeanutInvitation");

                EmailService.SendMessage(mailMessage);
            }
        }
Example #32
0
        public ActionResult Update(Peanut peanut, PeanutUpdateCommand peanutUpdateCommand, User currentUser)
        {
            if (!ModelState.IsValid)
            {
                IList <PeanutParticipationType> peanutParticipationTypes = PeanutParticipationTypeService.Find(peanut.UserGroup);
                return(View("Update", new PeanutUpdateViewModel(peanut, peanutUpdateCommand, peanutParticipationTypes)));
            }

            PeanutService.Update(peanut,
                                 peanutUpdateCommand.PeanutDto,
                                 peanutUpdateCommand.Requirements.Values.ToList(),
                                 peanutUpdateCommand.PeanutCommentCreateCommand.Comment,
                                 new PeanutUpdateNotificationOptions(peanutUpdateCommand.PeanutCommentCreateCommand.SendUpdateNotification,
                                                                     Url.Action("Show", "Peanut", new { peanut = peanut.BusinessId }, Request.Url.Scheme)),
                                 currentUser);

            return(RedirectToAction("Show", new { peanut = peanut.BusinessId }));
        }
Example #33
0
 public override void Execute(Peanut.FilterContext context)
 {
     Root.Default view = (Root.Default)context.View;
     if (Peanut.WebContext.Current.RequestType == Peanut.RequestType.POST)
     {
         if (view.Number !=0)
         {
             context.Execute();
         }
         else
         {
             view.Result = "Error number value!";
         }
     }
     else
     {
         context.Execute();
     }
 }
Example #34
0
        public Bill Create(UserGroup userGroup, BillDto billDto, UserGroupMembership creditor, IList <BillUserGroupDebitorDto> debitors,
                           IList <BillGuestDebitorDto> guestDebitors, Peanut peanut, User creator)
        {
            Require.NotNull(creator, "creator");
            Require.NotNull(userGroup, "userGroup");
            Require.NotNull(billDto, "billDto");
            Require.NotNull(creditor, "creditor");
            Require.NotNull(debitors, "debitors");
            Require.NotNull(guestDebitors, "guestDebitors");

            IList <BillUserGroupDebitor> debitorEntities      = GetDebitors(debitors, creator);
            IList <BillGuestDebitor>     guestDebitorEntities = GetGuestDebitors(guestDebitors);
            Bill bill = new Bill(userGroup, billDto, creditor, debitorEntities, guestDebitorEntities, new EntityCreatedDto(creator, DateTime.Now));

            if (peanut != null)
            {
                PeanutService.ClearPeanut(peanut, bill);
            }
            return(BillDao.Save(bill));
        }
Example #35
0
        public void SendPeanutUpdateNotification(Peanut peanut, PeanutDto dtoBeforeUpdate, IList <PeanutRequirement> requirementsBeforeUpdate,
                                                 string updateComment, PeanutUpdateNotificationOptions notificationOptions, User user)
        {
            Require.NotNull(peanut, "peanut");
            Require.NotNull(notificationOptions, "notificationOptions");
            string[]      differences   = peanut.GetDto() - dtoBeforeUpdate;
            StringBuilder updateSummary = new StringBuilder();

            if (differences != null && differences.Any())
            {
                foreach (string difference in differences)
                {
                    updateSummary.AppendLine(difference);
                }
            }
            else
            {
                updateSummary.AppendLine("-");
            }

            if (string.IsNullOrWhiteSpace(updateComment))
            {
                updateComment = "-";
            }

            foreach (PeanutParticipation peanutParticipation in FindParticipatorsToNotifyOnUpdate(peanut, user))
            {
                ModelMap modelMap = new ModelMap();
                modelMap.Add("peanut", peanut);
                modelMap.Add("peanutSourceName", dtoBeforeUpdate.Name);
                modelMap.Add("peanutSourceDay", dtoBeforeUpdate.Day);
                modelMap.Add("editor", user);
                modelMap.Add("recipient", peanutParticipation.UserGroupMembership.User);
                modelMap.Add("participation", peanutParticipation);
                modelMap.Add("peanutUrl", notificationOptions.PeanutUrl);
                modelMap.Add("updateSummary", updateSummary);
                modelMap.Add("comment", updateComment);
                MailMessage mailMessage = EmailService.CreateMailMessage(peanutParticipation.UserGroupMembership.User.Email, modelMap, "PeanutUpdated");
                EmailService.SendMessage(mailMessage);
            }
        }
Example #36
0
        public void UpdateState(Peanut peanut, PeanutState peanutState, PeanutUpdateNotificationOptions notificationOptions, User user)
        {
            Require.NotNull(peanut, "peanut");
            Require.NotNull(user, "user");

            if (peanut.PeanutState == peanutState)
            {
                /*Keine Änderung am Status*/
                return;
            }

            if (peanutState >= PeanutState.SchedulingDone && !peanut.IsFixed)
            {
                RemoveParticipations(peanut,
                                     peanut.Participations.Where(s => s.ParticipationState == PeanutParticipationState.Pending)
                                     .Select(s => s.UserGroupMembership)
                                     .ToList(),
                                     user);
            }
            peanut.UpdateState(peanutState, new EntityChangedDto(user, DateTime.Now));
            NotificationService.SendPeanutUpdateStateNotification(peanut, notificationOptions, user);
        }
        public static void Main()
        {
            Appetizer almonds = new Almond();
            Appetizer cashew  = new Cashew();
            Appetizer peanuts = new Peanut();

            Drink whiskey = new Whiskey("Johny Walker", 50, cashew);

            Console.WriteLine("--------- Drink with cashew appetizer:");
            whiskey.DisplayInformation();
            Console.WriteLine();

            whiskey.Appetizer = almonds;
            Console.WriteLine("--------- Drink with almonds appetizer:");
            whiskey.DisplayInformation();
            Console.WriteLine();

            whiskey.Appetizer = peanuts;
            Console.WriteLine("--------- Drink with peanuts appetizer:");
            whiskey.DisplayInformation();
            Console.WriteLine();
        }
Example #38
0
        private bool HasPeanutChanged(Peanut peanut, PeanutDto peanutDto, IList <RequirementDto> requirements)
        {
            if (!peanut.GetDto().Equals(peanutDto))
            {
                /*Es gab Änderungen an den allgemeinen Daten des Peanuts.*/
                return(true);
            }

            IList <RequirementDto> requirementsBefore = peanut.Requirements.Select(r => r.GetDto()).ToList();

            if (requirementsBefore.Except(requirements).Any())
            {
                /*Anforderungen wurden gelöscht*/
                return(true);
            }
            if (requirements.Except(requirementsBefore).Any())
            {
                /*Anforderungen wurden hinzugefügt*/
                return(true);
            }

            return(false);
        }
Example #39
0
            public object Execute(Peanut.RequestType type)
            {
                AjaxStatus result = new AjaxStatus();
                try
                {

                    Utils.ControlService.ControlArrowup(ControlID);
                }
                catch (Exception e)
                {
                    result.Error = e;
                }
                return result;
            }
Example #40
0
 public object Execute(Peanut.RequestType type)
 {
     return this;
 }