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 })); }
/// <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); }
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)))); }
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)); }
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 })); }
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); } }
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); } }
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 })); }
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); } } }
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))); }
public object Execute(Peanut.RequestType type) { if (type == Peanut.RequestType.POST ) { Result = string.Format("value:{0}", Number); } return this; }
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()))); }
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()); }
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; }
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()); } }
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; }
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 })); }
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 })); }
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); }
/// <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); }
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()); }
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); }
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 })); }
public object Execute(Peanut.RequestType type) { AjaxStatus result = new AjaxStatus(); try { Utils.ControlService.AddModule(ParentID, ModuleName); } catch (Exception e) { result.Error = e; } return result; }
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); }
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); } }
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); }
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; }
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); } }
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); } }
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); } }
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 })); }
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(); } }
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)); }
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); } }
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(); }
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); }
public object Execute(Peanut.RequestType type) { AjaxStatus result = new AjaxStatus(); try { Utils.ControlService.ControlArrowup(ControlID); } catch (Exception e) { result.Error = e; } return result; }
public object Execute(Peanut.RequestType type) { return this; }