Ejemplo n.º 1
0
 public ChangelogRowViewModel(Changelog row, MembersContainer container)
 {
     _row = row;
     _container = container;
     _dateTime = DateTime.Parse(String.Format("{0} {1}", _row.date, _row.time));
     _cachedDescription = new Lazy<string>(() => GetItemDescription(row));
 }
Ejemplo n.º 2
0
 private static string GetDescriptionFor(Changelog item, Member member, Contact contact)
 {
     switch (item.action)
     {
         case DBConstants.NewContact:
             return String.Format("Lisätty uusi yhteystieto jäsenelle {0} {1} ({2})",
                                  member.firstname, member.lastname, member.MemberDetais.membergroup);
         case DBConstants.DeleteContact:
             return String.Format("Yhteystieto poistettu jäseneltä {0} {1}",
                                   member.firstname, member.lastname);
         case DBConstants.EditContact:
             return String.Format("Yhteystiedolta {0} {1} ({2} {3}) muutettu {4}",
                                 contact.firstname, contact.lastname,
                                 member.firstname, member.lastname,
                                 item.oldvalue);
         case DBConstants.NewMember:
             return String.Format("Lisätty uusi jäsen {0} {1} ({2})",
                                 member.firstname, member.lastname, member.MemberDetais.membergroup);
         case DBConstants.EditMember:
             return String.Format("Muokattu jäsentä {0} {1} ({2}) tietoa {3}",
                                 member.firstname, member.lastname, member.MemberDetais.membergroup, item.oldvalue);
         case DBConstants.NewNonMember:
             return String.Format("Jäsen eronnut {0} {1} ({2}) syy: {3}",
                                 member.firstname, member.lastname, item.oldvalue, member.MemberDetais.membergroup);
         default:
             Debug.Assert(false, "Should not be reached");
             return "<Empty>";
     }
 }
Ejemplo n.º 3
0
        private Member GetMember(Changelog item)
        {
            IEnumerable<Member> rows = _container.MemberSet.AsEnumerable().
                                            Where(m => m.Id == long.Parse(item.memberid));
            if (rows.Count() == 0)
                return null;

            return rows.First();
        }
Ejemplo n.º 4
0
        private string GetItemDescription(Changelog item)
        {
            Member member = GetMember(item);
            Contact contact = GetContact(item);

            if (member == null && contact == null)
                return String.Format("Käyttäjä <{0}> puuttuu {1}", item.memberid, item.action);

            return GetDescriptionFor(item, member, contact);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Get the contact that is related to the change item.
        /// </summary>
        private Contact GetContact(Changelog item)
        {
            if (!item.action.Equals(DBConstants.EditContact))
                return null;

            var log = _container.ContactSet.AsEnumerable();
            IEnumerable<Contact> rows = log.Where(c => c.Member.Id == long.Parse(item.memberid) &&
                                                       c.Id == long.Parse(item.newvalue));

            return rows.FirstOrDefault();
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Create a new Changelog object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="action">Initial value of the action property.</param>
 /// <param name="newvalue">Initial value of the newvalue property.</param>
 /// <param name="oldvalue">Initial value of the oldvalue property.</param>
 /// <param name="memberid">Initial value of the memberid property.</param>
 /// <param name="time">Initial value of the time property.</param>
 /// <param name="date">Initial value of the date property.</param>
 public static Changelog CreateChangelog(global::System.Int64 id, global::System.String action, global::System.String newvalue, global::System.String oldvalue, global::System.String memberid, global::System.String time, global::System.String date)
 {
     Changelog changelog = new Changelog();
     changelog.Id = id;
     changelog.action = action;
     changelog.newvalue = newvalue;
     changelog.oldvalue = oldvalue;
     changelog.memberid = memberid;
     changelog.time = time;
     changelog.date = date;
     return changelog;
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Deprecated Method for adding a new object to the ChangelogSet EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToChangelogSet(Changelog changelog)
 {
     base.AddObject("ChangelogSet", changelog);
 }