public static bool Add_New_Item(RDN.Library.Classes.League.ItemInfoDA NewItem) { try { var dc = new ManagementContext(); DataModels.League.ItemInfo con = new DataModels.League.ItemInfo(); con.ItemSerialNo = NewItem.ItemSerialNo; con.ItemName = NewItem.ItemName; con.Location = NewItem.Location; con.Notes = NewItem.Notes; con.Quantity = NewItem.Quantity; con.UnitePice = NewItem.UnitePice; con.ItemsForLeague = dc.Leagues.Where(x => x.LeagueId == NewItem.ItemsForLeague).FirstOrDefault(); con.ItemAddByMember = dc.Members.Where(x => x.MemberId == NewItem.ItemAddByMember).FirstOrDefault(); dc.ItemInfos.Add(con); int c = dc.SaveChanges(); return c > 0; } catch (Exception exception) { ErrorDatabaseManager.AddException(exception, exception.GetType()); } return false; }
public static bool AddNewDesignation(RDN.Library.Classes.League.Organization designation) { try { var dc = new ManagementContext(); DataModels.League.OrganizationChart.Designation con = new DataModels.League.OrganizationChart.Designation(); con.DesignationTitle = designation.DesigTitle; con.DesignationLevel = designation.DesigLavel; con.ShortNote = designation.ShortNote; con.League = dc.Leagues.Where(x => x.LeagueId == designation.LeagueId).FirstOrDefault(); dc.Designations.Add(con); int c = dc.SaveChanges(); return c > 0; } catch (Exception exception) { ErrorDatabaseManager.AddException(exception, exception.GetType()); } return false; }
public static bool Add_New_Sponsor(RDN.Library.Classes.League.Sponsor NewSponsor) { try { var dc = new ManagementContext(); DataModels.League.Sponsorship con = new DataModels.League.Sponsorship(); con.Description = NewSponsor.Description; con.PromoCode = NewSponsor.PromoCode; con.SponsorName = NewSponsor.SponsorName; con.Website = NewSponsor.Website; if (NewSponsor.BeginDate != new DateTime()) con.BeginDate = NewSponsor.BeginDate; if (NewSponsor.EndDate != new DateTime()) con.EndDate = NewSponsor.EndDate; con.Sponsored = NewSponsor.Sponsored; con.SponsorForLeague = dc.Leagues.Where(x => x.LeagueId == NewSponsor.SponsorForLeague).FirstOrDefault(); con.SponsorAddByMember = dc.Members.Where(x => x.MemberId == NewSponsor.SponsorAddByMember).FirstOrDefault(); dc.Sponsorships.Add(con); int c = dc.SaveChanges(); return c > 0; } catch (Exception exception) { ErrorDatabaseManager.AddException(exception, exception.GetType(), additionalInformation: NewSponsor.EndDate + ":" + NewSponsor.BeginDate); } return false; }
public static bool Add_New_List(RDN.Library.Classes.League.TaskList.TaskListDA NewTaskList) { try { var dc = new ManagementContext(); DataModels.League.Task.TaskList con = new DataModels.League.Task.TaskList(); con.AssignedTo = NewTaskList.AssignedTo; con.EndDate = NewTaskList.EndDate; con.ListAddByMember = dc.Members.Where(x => x.MemberId == NewTaskList.ListAddByMember).FirstOrDefault(); con.ListName = NewTaskList.ListName; con.TaskListForLeague = dc.Leagues.Where(x => x.LeagueId == NewTaskList.TaskListForLeague).FirstOrDefault(); dc.TaskLists.Add(con); int c = dc.SaveChanges(); return c > 0; } catch (Exception exception) { ErrorDatabaseManager.AddException(exception, exception.GetType()); } return false; }
void AddEntry(string name, Connection conn, TreeIter iter) { try { Pixbuf pb = Pixbuf.LoadFromResource("x-directory-normal.png"); LdapEntry[] ldapEntries = conn.Data.GetEntryChildren(name); foreach (LdapEntry le in ldapEntries) { Log.Debug("\tchild: {0}", le.DN); DN dn = new DN(le.DN); RDN rdn = (RDN)dn.RDNs[0]; TreeIter newChild; newChild = browserStore.AppendValues(iter, pb, le.DN, rdn.Value); browserStore.AppendValues(newChild, pb, "", ""); } } catch { string msg = Mono.Unix.Catalog.GetString( "Unable to read data from server"); HIGMessageDialog dialog = new HIGMessageDialog( parent, 0, Gtk.MessageType.Error, Gtk.ButtonsType.Ok, "Network error", msg); dialog.Run(); dialog.Destroy(); } }
public static bool Add_New_SubscriptionList(RDN.Library.Classes.EmailServer.SubscriptionFactory NewList) { try { var dc = new ManagementContext(); DataModels.EmailServer.Subscriptions.SubscriptionList con = new DataModels.EmailServer.Subscriptions.SubscriptionList(); con.ListName = NewList.ListName; con.SubscriberTypeEnum = NewList.SubscriberTypeEnum; con.IsRemoved = false; dc.SubscriptionLists.Add(con); //DataModels.EmailServer.Subscriptions.SubscriptionOwner ownerCon = new DataModels.EmailServer.Subscriptions.SubscriptionOwner(); //ownerCon.LeagueOwner = dc.Leagues.Where(x => x.LeagueId == NewList.LeagueOwner).FirstOrDefault(); //ownerCon.Owner = dc.Members.Where(x => x.MemberId == NewList.owner).FirstOrDefault(); //ownerCon.IsRemoved = false; //dc.SubscriptionOwners.Add(ownerCon); int c = dc.SaveChanges(); return c > 0; } catch (Exception exception) { ErrorDatabaseManager.AddException(exception, exception.GetType()); } return false; }
public static bool Add_New_Task(RDN.Library.Classes.League.TaskList.TaskDA NewTask) { try { var dc = new ManagementContext(); DataModels.League.Task.Task con = new DataModels.League.Task.Task(); con.Completed = NewTask.Completed; con.Title = NewTask.Title; con.DeadLine = NewTask.DeadLine; con.EndDate = NewTask.EndDate; con.Notes = NewTask.Notes; con.StartDate = NewTask.StartDate; con.StatusId = NewTask.StatusId; con.TaskAddByMember = dc.Members.Where(x => x.MemberId == NewTask.TaskAddByMember).FirstOrDefault(); con.TaskBelongsTo = dc.TaskLists.Where(x => x.ListId == NewTask.TaskListId).FirstOrDefault(); dc.Tasks.Add(con); int c = dc.SaveChanges(); return c > 0; } catch (Exception exception) { ErrorDatabaseManager.AddException(exception, exception.GetType()); } return false; }
public static string ToFriendlyName(this RDN source) { var result = String.Empty; foreach (RDNComponent comp in source.Components) { result += String.Format("{0}+", comp.ComponentValue); } result = result.TrimEnd('+'); return(result); }
public static long SaveBoutRequestList(Guid leagieId, RDN.Library.Classes.League.BoutList boutList) { try { var dc = new ManagementContext(); DataModels.Bouts.BoutList con = new DataModels.Bouts.BoutList(); con.Location = boutList.Location; con.RuleSetId = boutList.RuleSetId; con.TravelStipendAmount = boutList.TravelStipendAmount; con.IsStreamLive = boutList.IsStreamLive; con.IsSkaterHousingOffered = boutList.IsSkaterHousingOffered; con.IsOfferTravelStipend = boutList.IsOfferTravelStipend; con.IsHangOverBoutOffered = boutList.IsHangOverBoutOffered; con.EventInformation = boutList.EventInformation; con.DateOfEvent = boutList.StartDateOfEvent; con.CurrentRanking = boutList.CurrentRanking; con.CrowdSize = boutList.CrowdSize; con.IsPublic = boutList.DisplayToPublic; con.IsAwayGame = boutList.IsAwayGame; if (boutList.EndDateOfEvent > DateTime.UtcNow.AddYears(-1)) con.EndDateOfEvent = boutList.EndDateOfEvent; con.League = dc.Leagues.Where(x => x.LeagueId == leagieId).FirstOrDefault(); dc.BoutLists.Add(con); int c = dc.SaveChanges(); //return c > 0; return con.ChallengeId; } catch (Exception exception) { ErrorDatabaseManager.AddException(exception, exception.GetType(), additionalInformation: boutList.StartDateOfEvent + ":" + boutList.EndDateOfEvent); } return 0; }
public static bool AddNewJob(RDN.Library.Classes.League.JobBoard jobBoard) { try { var dc = new ManagementContext(); DataModels.League.JobBoard con = new DataModels.League.JobBoard(); con.JobTitle = jobBoard.JobTitle; con.JobDesc = jobBoard.JobDesc; con.ReportsTo = jobBoard.ReportsTo; con.HoursPerWeek = jobBoard.HoursPerWeek; con.JobEnds = jobBoard.JobEnds; con.League = dc.Leagues.Where(x => x.LeagueId == jobBoard.LeagueId).FirstOrDefault(); con.JobCreator = dc.Members.Where(x => x.MemberId == jobBoard.JobCreator).FirstOrDefault(); dc.JobBoards.Add(con); int c = dc.SaveChanges(); if (jobBoard.BroadcastJob) { var mems = LeagueFactory.GetLeagueMembersNotificationSettings(jobBoard.LeagueId); foreach (var member in mems) { SendEmailAboutNewBroadcast(member.UserId, member.DerbyName, con.JobId, jobBoard.LeagueId, jobBoard.JobTitle); } } return c > 0; } catch (Exception exception) { ErrorDatabaseManager.AddException(exception, exception.GetType()); } return false; }
public static RDN.Portable.Classes.League.Classes.League UpdateLeagueDisplay(RDN.Portable.Classes.League.Classes.League league, Guid memberId) { try { var cached = GetCache(memberId, true); cached.CurrentLeague = league; UpdateCache(cached); } catch (Exception exception) { ErrorDatabaseManager.AddException(exception, exception.GetType()); } return league; }
public InvoiceFactory AddItemTaxIncluded(RDN.Library.Classes.Payment.Classes.Invoice.InvoiceItem item) { if (string.IsNullOrEmpty(item.Description)) throw new Exception("Invalid item description"); if (string.IsNullOrEmpty(item.Name)) throw new Exception("Invalid item name"); if (item.Price < 0) throw new Exception("Item price can not be negative"); //if (item.Quantity < 1) // throw new Exception("Item quantity can not be below 1"); if (item.Weight < 0) throw new Exception("Item weight can not be negative"); if (item.BasePrice < 0) throw new Exception("Item base price can not be negative"); if (item.Quantity > 0) { invoice.ItemsInvoice.Add(item); invoice.FinancialData.BasePriceForItems += item.Price; } return this; }
public static bool UpdateSubscriberInfo(RDN.Library.Classes.EmailServer.SubscriptionFactory SubscriberToUpdate) { try { var dc = new ManagementContext(); var dbSponsor = dc.SubscriptionSubscriber.Where(x => x.SubscriberId == SubscriberToUpdate.SubscriberId).FirstOrDefault(); if (dbSponsor == null) return false; dbSponsor.Name = SubscriberToUpdate.Name; // dbSponsor.SubscriberTypeEnum = SubscriberToUpdate.SubscriberTypeEnum; dbSponsor.Data = SubscriberToUpdate.Data; dbSponsor.OptedOut = SubscriberToUpdate.OptedOut; // dbSponsor.OptedOutDateTime = SubscriberToUpdate.OptedOutDateTime; int c = dc.SaveChanges(); return c > 0; } catch (Exception exception) { ErrorDatabaseManager.AddException(exception, exception.GetType()); } return false; }
public static bool Add_New_Subscriber(RDN.Library.Classes.EmailServer.SubscriptionFactory NewData) { try { var dc = new ManagementContext(); DataModels.EmailServer.Subscriptions.Subscriber con = new DataModels.EmailServer.Subscriptions.Subscriber(); con.BounceCount = NewData.BounceCount; con.Data = NewData.Data; con.EmailsSent = NewData.EmailsSent; con.IsRemoved = false; con.List = dc.SubscriptionLists.Where(x => x.ListId == NewData.listId).FirstOrDefault(); con.Name = NewData.Name; con.OptedOut = NewData.OptedOut; // con.OptedOutDateTime = NewData.OptedOutDateTime; // con.SubscriberTypeEnum = NewData.SubscriberTypeEnum; dc.SubscriptionSubscriber.Add(con); DataModels.EmailServer.Subscriptions.SubscriptionOwner subsOwner = new DataModels.EmailServer.Subscriptions.SubscriptionOwner(); subsOwner.IsRemoved = false; subsOwner.List = dc.SubscriptionLists.Where(x => x.ListId == NewData.listId).FirstOrDefault(); subsOwner.LeagueOwner = dc.Leagues.Where(x => x.LeagueId == NewData.LeagueOwner).FirstOrDefault(); dc.SubscriptionOwners.Add(subsOwner); int c = dc.SaveChanges(); return c > 0; } catch (Exception exception) { ErrorDatabaseManager.AddException(exception, exception.GetType()); } return false; }
public static bool UpdateListInfo(RDN.Library.Classes.EmailServer.SubscriptionFactory DataToUpdate) { try { var dc = new ManagementContext(); var dbData = dc.SubscriptionLists.Where(x => x.ListId == DataToUpdate.listId).FirstOrDefault(); if (dbData == null) return false; dbData.ListName = DataToUpdate.ListName; int c = dc.SaveChanges(); return c > 0; } catch (Exception exception) { ErrorDatabaseManager.AddException(exception, exception.GetType()); } return false; }
//[Obsolete] //public static void AddTrialSubscriptionsToAllCurrentLeagues() //{ // try // { // var dc = new ManagementContext(); // var dbLeague = dc.Leagues.ToList(); // foreach (var league in dbLeague) // { // league.SubscriptionPeriodEnds = DateTime.UtcNow.AddDays(58); // } // dc.SaveChanges(); // } // catch (Exception exception) // { // ErrorDatabaseManager.AddException(exception, exception.GetType()); // } //} public static void UpdateLeagueForFederation(Guid federationId, RDN.Portable.Classes.League.Classes.League league) { try { var dc = new ManagementContext(); var dbLeague = dc.Leagues.Where(x => x.LeagueId == league.LeagueId).FirstOrDefault(); if (dbLeague != null) { dbLeague.Name = league.Name; var address = dbLeague.ContactCard.Addresses.FirstOrDefault(); address.CityRaw = league.City; address.StateRaw = league.State; var country = dc.Countries.Where(x => x.Name == league.Country).FirstOrDefault(); if (country != null) { address.Country = country; } dc.SaveChanges(); } var fedLeague = dc.FederationLeagues.Where(x => x.Federation.FederationId == federationId && x.League.LeagueId == league.LeagueId).FirstOrDefault(); if (fedLeague != null) { fedLeague.InternalLeagueIdForFederation = league.InternalFederationIdForLeague; dc.SaveChanges(); } } catch (Exception exception) { ErrorDatabaseManager.AddException(exception, exception.GetType()); } }
public static bool UpdateTaskInfo(RDN.Library.Classes.League.TaskList.TaskDA TaskToUpdate) { try { var dc = new ManagementContext(); var dbList = dc.Tasks.Where(x => x.TaskId == TaskToUpdate.TaskId).FirstOrDefault(); if (dbList == null) return false; dbList.Completed = TaskToUpdate.Completed; dbList.Title = TaskToUpdate.Title; dbList.DeadLine = TaskToUpdate.DeadLine; dbList.EndDate = TaskToUpdate.EndDate; dbList.Notes = TaskToUpdate.Notes; dbList.StartDate = TaskToUpdate.StartDate; dbList.StatusId = TaskToUpdate.StatusId; dbList.TaskAddByMember.MemberId = TaskToUpdate.TaskAddByMember; dbList.TaskBelongsTo.ListId = TaskToUpdate.TaskListId; int c = dc.SaveChanges(); return c > 0; } catch (Exception exception) { ErrorDatabaseManager.AddException(exception, exception.GetType()); } return false; }
/// <summary> /// updates the league to the matching league item /// </summary> /// <param name="leagueToUpdate"></param> /// <returns></returns> public static bool UpdateLeague(RDN.Portable.Classes.League.Classes.League leagueToUpdate, Stream fileStream, string nameOfFile) { try { var dc = new ManagementContext(); var league = dc.Leagues.Include("ContactCard").Where(x => x.LeagueId == leagueToUpdate.LeagueId).FirstOrDefault(); league.Name = leagueToUpdate.Name; league.WebSite = leagueToUpdate.Website; league.Twitter = leagueToUpdate.Twitter; league.Instagram = leagueToUpdate.Instagram; league.Facebook = leagueToUpdate.Facebook; league.RuleSetsPlayedEnum = (long)leagueToUpdate.RuleSetsPlayedEnum; league.CultureLCID = leagueToUpdate.CultureSelected; UpdateLeagueColors(leagueToUpdate, dc, league); if (leagueToUpdate.Founded != null && leagueToUpdate.Founded != new DateTime() && leagueToUpdate.Founded > DateTime.UtcNow.AddYears(-100)) league.Founded = leagueToUpdate.Founded; if (fileStream != null) AddLogoForLeague(fileStream, nameOfFile, league.LeagueId); league.InternalWelcomeMessage = leagueToUpdate.InternalWelcomeMessage; var emailDb = league.ContactCard.Emails.Where(x => x.IsDefault == true).FirstOrDefault(); if (emailDb != null) { emailDb.EmailAddress = leagueToUpdate.Email; } else { Email em = new Email(); em.ContactCard = league.ContactCard; em.EmailAddress = leagueToUpdate.Email; em.IsDefault = true; league.ContactCard.Emails.Add(em); } //int numberType = Convert.ToInt32(CommunicationTypeEnum.PhoneNumber); var phone = league.ContactCard.Communications.Where(x => x.CommunicationTypeEnum == (byte)CommunicationTypeEnum.PhoneNumber).FirstOrDefault(); if (phone != null) phone.Data = leagueToUpdate.PhoneNumber; else { Communication com = new Communication(); com.Data = leagueToUpdate.PhoneNumber; //com.CommunicationType = dc.CommunicationType.Where(x => x.CommunicationTypeId == numberType).FirstOrDefault(); com.CommunicationTypeEnum = (byte)CommunicationTypeEnum.PhoneNumber; com.ContactCard = league.ContactCard; com.IsDefault = true; league.ContactCard.Communications.Add(com); } var addresses = league.ContactCard.Addresses.Where(x => x.IsDefault == true).FirstOrDefault(); if (addresses == null) if (league.ContactCard.Addresses.Count > 0) addresses = league.ContactCard.Addresses.FirstOrDefault(); if (addresses == null) { addresses = new Address(); addresses.ContactCard = league.ContactCard; } addresses.CityRaw = leagueToUpdate.City; addresses.StateRaw = leagueToUpdate.State; addresses.Zip = leagueToUpdate.ZipCode; var countryDb = dc.Countries.Where(x => x.Name.ToLower() == leagueToUpdate.Country.ToLower()).FirstOrDefault(); if (countryDb == null) countryDb = dc.Countries.Where(x => x.Code.ToLower() == leagueToUpdate.Country.ToLower()).FirstOrDefault(); addresses.Country = countryDb; var coords = OpenStreetMap.FindLatLongOfAddress(addresses.Address1, addresses.Address2, addresses.Zip, addresses.CityRaw, addresses.StateRaw, addresses.Country != null ? addresses.Country.Name : string.Empty); if (coords != null) { addresses.Coords = new System.Device.Location.GeoCoordinate(); addresses.Coords.Latitude = coords.Latitude; addresses.Coords.Longitude = coords.Longitude; addresses.Coords.Altitude = 0; addresses.Coords.Course = 0; addresses.Coords.HorizontalAccuracy = 1; addresses.Coords.Speed = 0; addresses.Coords.VerticalAccuracy = 1; } addresses.IsDefault = true; int c = dc.SaveChanges(); return c > 0; } catch (Exception exception) { ErrorDatabaseManager.AddException(exception, exception.GetType()); } return false; }
public ActionResult EditLeague(RDN.League.Models.League.LeagueModel league, HttpPostedFileBase file) { try { var memid = RDN.Library.Classes.Account.User.GetMemberId(); var isManager = MemberCache.IsManagerOrBetterOfLeague(memid); bool isAdmin = MemberCache.IsAdministrator(memid); if (!isAdmin && !isManager) return Redirect(Url.Content("~/?u=" + SiteMessagesEnum.na)); RDN.Portable.Classes.League.Classes.League leag = league; leag.InternalWelcomeMessage = league.InternalWelcomeMessageModel; bool made = false; if (Request.Form[RuleSetsUsedEnum.MADE.ToString()] != null) made = Request.Form[RuleSetsUsedEnum.MADE.ToString()].Contains("true"); bool OSDA = false; if (Request.Form[RuleSetsUsedEnum.OSDA.ToString()] != null) OSDA = Request.Form[RuleSetsUsedEnum.OSDA.ToString()].Contains("true"); bool RDCL = false; if (Request.Form[RuleSetsUsedEnum.RDCL.ToString()] != null) RDCL = Request.Form[RuleSetsUsedEnum.RDCL.ToString()].Contains("true"); bool Renegade = false; if (Request.Form[RuleSetsUsedEnum.Renegade.ToString()] != null) Renegade = Request.Form[RuleSetsUsedEnum.Renegade.ToString()].Contains("true"); bool Texas_Derby = false; if (Request.Form[RuleSetsUsedEnum.Texas_Derby.ToString()] != null) Texas_Derby = Request.Form[RuleSetsUsedEnum.Texas_Derby.ToString()].Contains("true"); bool The_WFTDA = false; if (Request.Form[RuleSetsUsedEnum.The_WFTDA.ToString()] != null) The_WFTDA = Request.Form[RuleSetsUsedEnum.The_WFTDA.ToString()].Contains("true"); bool USARS = false; if (Request.Form[RuleSetsUsedEnum.USARS.ToString()] != null) USARS = Request.Form[RuleSetsUsedEnum.USARS.ToString()].Contains("true"); if (made) league.RuleSetsPlayedEnum |= RuleSetsUsedEnum.MADE; if (OSDA) league.RuleSetsPlayedEnum |= RuleSetsUsedEnum.OSDA; if (RDCL) league.RuleSetsPlayedEnum |= RuleSetsUsedEnum.RDCL; if (Renegade) league.RuleSetsPlayedEnum |= RuleSetsUsedEnum.Renegade; if (Texas_Derby) league.RuleSetsPlayedEnum |= RuleSetsUsedEnum.Texas_Derby; if (The_WFTDA) league.RuleSetsPlayedEnum |= RuleSetsUsedEnum.The_WFTDA; if (USARS) league.RuleSetsPlayedEnum |= RuleSetsUsedEnum.USARS; if (file == null) RDN.Library.Classes.League.LeagueFactory.UpdateLeague(league, null, null); else RDN.Library.Classes.League.LeagueFactory.UpdateLeague(league, file.InputStream, file.FileName); MemberCache.Clear(memid); MemberCache.ClearApiCache(memid); return Redirect(Url.Content("~/league/edit/" + league.LeagueId.ToString().Replace("-", "") + "?u=" + SiteMessagesEnum.s)); } catch (Exception exception) { ErrorDatabaseManager.AddException(exception, GetType()); } return Redirect(Url.Content("~/league/edit/" + league.LeagueId.ToString().Replace("-", ""))); }
public static int UpdateCalendarSettings(RDN.Portable.Classes.Controls.Calendar.Calendar calendar) { try { var dc = new ManagementContext(); var cal = dc.Calendar.Where(x => x.CalendarId == calendar.CalendarId).FirstOrDefault(); cal.AllowSelfCheckIn = calendar.AllowSelfCheckIn; cal.NotPresentCheckIn = calendar.NotPresentCheckIn; cal.DisableStartSkatingDays = calendar.DisableSkatingStartDates; cal.DisableBirthdaysFromShowing = calendar.DisableBirthdays; cal.TimeZoneSelection = dc.TimeZone.Where(x => x.ZoneId == calendar.TimeZoneId).FirstOrDefault(); if (cal.TimeZoneSelection != null) cal.TimeZone = cal.TimeZoneSelection.GMTOffset; cal.IsCalendarInUTC = true; return dc.SaveChanges(); } catch (Exception exception) { ErrorDatabaseManager.AddException(exception, exception.GetType()); } return 0; }
public static bool UpdateJob(RDN.Library.Classes.League.JobBoard JobToUpdate) { try { var dc = new ManagementContext(); var dbJob = dc.JobBoards.Where(x => x.JobId == JobToUpdate.JobId).FirstOrDefault(); if (dbJob == null) return false; dbJob.JobDesc = JobToUpdate.JobDesc; dbJob.JobEnds = JobToUpdate.JobEnds; dbJob.JobTitle = JobToUpdate.JobTitle; dbJob.ReportsTo = JobToUpdate.ReportsTo; dbJob.HoursPerWeek = JobToUpdate.HoursPerWeek; int c = dc.SaveChanges(); return c > 0; } catch (Exception exception) { ErrorDatabaseManager.AddException(exception, exception.GetType()); } return false; }
public ActionResult CheckOut(RDN.Store.Models.CheckOut model) { try { var shoppingCartId = StoreGateway.GetShoppingCartId(HttpContext); if (!shoppingCartId.HasValue) { return Redirect(Url.Action("StoreCart")); } var sg = new StoreGateway(); var checkout = sg.GetCheckoutData(shoppingCartId.Value, model.MerchantId); if (checkout == null || checkout.ShoppingCart.ItemsCount == 0) { return Redirect(Url.Action("StoreCart")); } PaymentProvider paymentProvider; if (!Enum.TryParse(model.PaymentProviderId, out paymentProvider)) { return Redirect(Url.Action("StoreCart")); } var pg = new PaymentGateway(); ShippingType shipType = ShippingType.Postal; if (checkout.WillPickUpAtStore) shipType = ShippingType.PickUp; var invoice = pg.StartInvoiceWizard() .Initalize(checkout.MerchantId, checkout.Currency, paymentProvider, PaymentMode.Live, ChargeTypeEnum.InStorePurchase) .SetShipping(checkout.TotalShipping, shipType) .SetInvoiceId(Guid.NewGuid()) .SetNotes(model.Notes) .SetUserId(RDN.Library.Classes.Account.User.GetUserId()) .SetShoppingCartId(shoppingCartId.Value); if (paymentProvider == PaymentProvider.Stripe) { string token = Request.Form["stripeToken"].ToString(); invoice.SetStripeTokenId(token); } var sellersAddress = new InvoiceContactInfo(); if (shipType == ShippingType.PickUp) { if (checkout.SellersAddress != null) { sellersAddress.City = checkout.SellersAddress.City; sellersAddress.Country = checkout.SellersAddress.Country; sellersAddress.CompanyName = checkout.SellersAddress.CompanyName; sellersAddress.State = checkout.SellersAddress.State; sellersAddress.Street = checkout.SellersAddress.Street; sellersAddress.Street2 = checkout.SellersAddress.Street2; sellersAddress.Zip = checkout.SellersAddress.Zip; invoice.SetSellersAddress(sellersAddress); } } var billingInfo = new InvoiceContactInfo(); billingInfo.City = model.BillingAddress_City; billingInfo.Country = model.BillingAddress_Country; billingInfo.Email = model.BillingAddress_Email; billingInfo.FirstName = model.BillingAddress_FirstName; billingInfo.LastName = model.BillingAddress_LastName; billingInfo.Phone = model.BillingAddress_Phone; billingInfo.State = model.BillingAddress_State; billingInfo.Street = model.BillingAddress_Street; billingInfo.Street2 = model.BillingAddress_Street2; billingInfo.Zip = model.BillingAddress_Zip; if (User.Identity.IsAuthenticated) RDN.Library.Classes.Account.User.AddContactToMember(RDN.Library.Classes.Account.User.GetMemberId(), billingInfo, AddressTypeEnum.Billing); if (model.IsBillingDifferentFromShipping) { var shippingInfo = new InvoiceContactInfo(); shippingInfo.City = model.ShippingAddress_City; shippingInfo.Country = model.ShippingAddress_Country; shippingInfo.Email = model.ShippingAddress_Email; shippingInfo.FirstName = model.ShippingAddress_FirstName; shippingInfo.LastName = model.ShippingAddress_LastName; shippingInfo.Phone = model.ShippingAddress_Phone; shippingInfo.State = model.ShippingAddress_State; shippingInfo.Street = model.ShippingAddress_Street; shippingInfo.Street2 = model.ShippingAddress_Street2; shippingInfo.Zip = model.ShippingAddress_Zip; invoice.SetInvoiceContactData(billingInfo, shippingInfo); if (User.Identity.IsAuthenticated) RDN.Library.Classes.Account.User.AddContactToMember(RDN.Library.Classes.Account.User.GetMemberId(), shippingInfo, AddressTypeEnum.Shipping); } else invoice.SetInvoiceContactData(billingInfo, billingInfo); foreach (var cartitem in checkout.ShoppingCart.Stores.FirstOrDefault().StoreItems) { var item = new InvoiceItem(); item.ArticleNumber = cartitem.ArticleNumber; item.Article2Number = cartitem.Article2Number; item.Description = "Tax Included in Price: " + cartitem.Description; item.Name = cartitem.Name; item.BasePrice = cartitem.BasePrice + cartitem.BaseTaxOnItem; item.Price = cartitem.Price; item.TotalShipping = cartitem.Shipping; item.Quantity = cartitem.QuantityOrdered; item.Weight = cartitem.Weight; item.SizeOfItem = cartitem.ItemSizeEnum; item.ColorOfItem = cartitem.ColorAGB; item.StoreItemId = cartitem.StoreItemId; invoice.AddItemTaxIncluded(item); } var requestResponse = invoice.FinalizeInvoice(); if (requestResponse.Error != null) throw new Exception(requestResponse.Error); this.ClearCart(HttpContext.Session); if (requestResponse.Status == InvoiceStatus.Payment_Successful) return Redirect(Url.Content("~/receipt/" + requestResponse.InvoiceId.ToString().Replace("-", ""))); else if (requestResponse.Status == InvoiceStatus.Pending_Payment_From_Paypal) return Redirect(requestResponse.RedirectLink); } catch (Exception exception) { ErrorDatabaseManager.AddException(exception, exception.GetType()); } return Redirect(Url.Content("~/?u=" + SiteMessagesEnum.sww)); }
public void OnPasteActivate(object o, EventArgs args) { if (!(viewNotebook.Page == 1)) { return; } Connection conn = GetActiveConnection(); if (conn == null) { return; } if (conn.Settings.Name != editName) { string msg = Mono.Unix.Catalog.GetString("Cannot copy/cut enteries between servers"); HIGMessageDialog dialog = new HIGMessageDialog( mainWindow, 0, Gtk.MessageType.Error, Gtk.ButtonsType.Ok, "Paste error", msg.ToString()); dialog.Run(); dialog.Destroy(); return; } string pasteDN = ldapTreeView.GetSelectedDN(); if (pasteDN == null) { return; } DN dn = new DN(editDN); RDN r = (RDN)dn.RDNs [0]; try { if (editIsCopy) { conn.Data.Copy(editDN, r.toString(false), pasteDN); WriteStatusMessage("Entry copied"); } else { conn.Data.Move(editDN, r.toString(false), pasteDN); ldapTreeView.RemoveRow(editIter); WriteStatusMessage("Entry moved."); } } catch (Exception e) { Log.Debug(e); StringBuilder msg = new StringBuilder(); if (editIsCopy) { msg.AppendFormat("{0} {1}", Mono.Unix.Catalog.GetString("Unable to copy entry "), editDN); } else { msg.AppendFormat("{0} {1}", Mono.Unix.Catalog.GetString("Unable to move entry "), editDN); } msg.AppendFormat("\nError: {0}", e.Message); HIGMessageDialog dialog = new HIGMessageDialog( mainWindow, 0, Gtk.MessageType.Error, Gtk.ButtonsType.Ok, "Paste error", msg.ToString()); dialog.Run(); dialog.Destroy(); } if (editIsCopy) { editIsCopy = false; } editDN = null; editName = null; }
public static bool UpdateSponsorInfo(RDN.Library.Classes.League.Sponsor SponsorToUpdate) { try { var dc = new ManagementContext(); var dbSponsor = dc.Sponsorships.Where(x => x.SponsorId == SponsorToUpdate.SponsorId).FirstOrDefault(); if (dbSponsor == null) return false; dbSponsor.SponsorName = SponsorToUpdate.SponsorName; dbSponsor.PromoCode = SponsorToUpdate.PromoCode; dbSponsor.Description = SponsorToUpdate.Description; dbSponsor.Website = SponsorToUpdate.Website; dbSponsor.BeginDate = SponsorToUpdate.BeginDate; dbSponsor.EndDate = SponsorToUpdate.EndDate; dbSponsor.Sponsored = SponsorToUpdate.Sponsored; int c = dc.SaveChanges(); return c > 0; } catch (Exception exception) { ErrorDatabaseManager.AddException(exception, exception.GetType()); } return false; }
/// <summary> /// Update Event Information /// </summary> /// <param name="challengeId"></param> /// <param name="leagueId"></param> /// <param name="EventToUpdate"></param> /// <returns></returns> public static bool UpdateEvent(RDN.Library.Classes.League.BoutList EventToUpdate) { try { var dc = new ManagementContext(); var dbBoutList = dc.BoutLists.Where(x => x.ChallengeId == EventToUpdate.ChallengeId).FirstOrDefault(); if (dbBoutList == null) return false; dbBoutList.CrowdSize = EventToUpdate.CrowdSize; dbBoutList.CurrentRanking = EventToUpdate.CurrentRanking; dbBoutList.DateOfEvent = EventToUpdate.StartDateOfEvent; dbBoutList.EventInformation = EventToUpdate.EventInformation; dbBoutList.IsHangOverBoutOffered = EventToUpdate.IsHangOverBoutOffered; dbBoutList.IsOfferTravelStipend = EventToUpdate.IsOfferTravelStipend; dbBoutList.IsSkaterHousingOffered = EventToUpdate.IsSkaterHousingOffered; dbBoutList.IsStreamLive = EventToUpdate.IsStreamLive; dbBoutList.Location = EventToUpdate.Location; dbBoutList.RuleSetId = EventToUpdate.RuleSetId; dbBoutList.TravelStipendAmount = EventToUpdate.TravelStipendAmount; if (EventToUpdate.EndDateOfEvent > new DateTime()) dbBoutList.EndDateOfEvent = EventToUpdate.EndDateOfEvent; else dbBoutList.EndDateOfEvent = null; dbBoutList.IsAwayGame = EventToUpdate.IsAwayGame; dbBoutList.IsPublic = EventToUpdate.DisplayToPublic; int c = dc.SaveChanges(); return c > 0; } catch (Exception exception) { ErrorDatabaseManager.AddException(exception, exception.GetType()); } return false; }
/// <summary> /// Add an invoice item to the order /// </summary> /// <param name="item"></param> /// <returns></returns> public InvoiceFactory AddItem(RDN.Library.Classes.Payment.Classes.Invoice.InvoiceItem item) { if (string.IsNullOrEmpty(item.ArticleNumber)) throw new Exception("Invalid item article number"); if (string.IsNullOrEmpty(item.Description)) throw new Exception("Invalid item description"); if (string.IsNullOrEmpty(item.Name)) throw new Exception("Invalid item name"); if (item.Price < 0) throw new Exception("Item price can not be negative"); if (item.Quantity < 1) throw new Exception("Item quantity can not be below 1"); if (item.Weight < 0) throw new Exception("Item weight can not be negative"); if (item.BasePrice < 0) throw new Exception("Item base price can not be negative"); invoice.ItemsInvoice.Add(item); invoice.FinancialData.BasePriceForItems += item.Price; RecalculateTotalAfterTax(); return this; }
/// <summary> Returns the individual components of a relative distinguished name /// (RDN), normalized. /// /// </summary> /// <param name="rdn"> The relative distinguished name, or in other words, /// the left-most component of a distinguished name. /// /// </param> /// <param name="noTypes"> If true, returns only the values of the /// components, and not the names of the component, for /// example "Babs Jensen" instead of "cn=Babs Jensen". /// /// </param> /// <returns> An array of strings representing the individual components /// of an RDN, or null if the RDN is not a valid RDN. /// </returns> public static string[] explodeRDN(string rdn, bool noTypes) { RDN rdnToExplode = new RDN(rdn); return(rdnToExplode.explodeRDN(noTypes)); }
private static void UpdateLeagueColors(RDN.Portable.Classes.League.Classes.League leagueToUpdate, ManagementContext dc, DataModels.League.League league) { //removes any colors not being used anymore. List<int> colors = new List<int>(); if (!String.IsNullOrEmpty(leagueToUpdate.ColorsSelected)) { foreach (string color in leagueToUpdate.ColorsSelected.Split(';')) { if (color.Length > 3) { Color c = ColorTranslator.FromHtml(color); int arb = c.ToArgb(); colors.Add(arb); } } } var colorsNoLongerIn = league.Colors.Where(x => !colors.Contains(x.Color.ColorIdCSharp)).ToList(); foreach (var removeColor in colorsNoLongerIn) { league.Colors.Remove(removeColor); } //adds colors that are not currently added to the storeitem. if (!String.IsNullOrEmpty(leagueToUpdate.ColorsSelected)) { foreach (string color in leagueToUpdate.ColorsSelected.Split(';')) { if (color.Length > 3) { Color c = ColorTranslator.FromHtml(color); int arb = c.ToArgb(); if (league.Colors.Where(x => x.Color.ColorIdCSharp == arb).FirstOrDefault() == null) { var colorDb = dc.Colors.Where(x => x.ColorIdCSharp == arb).FirstOrDefault(); if (colorDb != null) { DataModels.League.LeagueColor cItem = new DataModels.League.LeagueColor(); cItem.Color = colorDb; cItem.League = league; league.Colors.Add(cItem); } } } } } }
public static bool UpdateItemInfo(RDN.Library.Classes.League.ItemInfoDA ItemToUpdate) { try { var dc = new ManagementContext(); var dbItem = dc.ItemInfos.Where(x => x.ItemId == ItemToUpdate.ItemId).FirstOrDefault(); if (dbItem == null) return false; dbItem.ItemName = ItemToUpdate.ItemName; dbItem.Location = ItemToUpdate.Location; dbItem.Notes = ItemToUpdate.Notes; dbItem.Quantity = ItemToUpdate.Quantity; dbItem.UnitePice = ItemToUpdate.UnitePice; dbItem.ItemSerialNo = ItemToUpdate.ItemSerialNo; int c = dc.SaveChanges(); return c > 0; } catch (Exception exception) { ErrorDatabaseManager.AddException(exception, exception.GetType()); } return false; }
public ActionResult EditLeague(RDN.Portable.Classes.League.Classes.League league) { var federation = MemberCache.GetAllOwnedFederations(RDN.Library.Classes.Account.User.GetMemberId()).FirstOrDefault().Federation; ViewBag.FederationName = federation.Name; RDN.Library.Classes.League.LeagueFactory.UpdateLeagueForFederation(federation.FederationId, league); league = RDN.Library.Classes.League.LeagueFactory.GetLeagueForFederation(federation.FederationId, league.LeagueId); ViewBag.Saved = true; return View(league); }
/// <summary> /// Gets a DN object representing a child object of the current DN. /// </summary> /// <param name="childRDN">a string representing the relative path to the child object</param> /// <returns>a DN object representing a child object of the current DN</returns> public DN GetChild(string childRDN) { DN childDN = new DN(childRDN); if (childDN.rDNs.Length > 0) { RDN[] fullPath = new RDN[this.RDNs.Length + childDN.rDNs.Length]; for (int i = 0; i < childDN.rDNs.Length; i++) { fullPath[i] = childDN.rDNs[i]; } for (int j = 0; j < this.rDNs.Length; j++) { fullPath[j + childDN.rDNs.Length] = this.rDNs[j]; } return new DN(new RDNList(fullPath), this.CharsToEscape); } else { return this; } }
public ActionResult RemoveLeague(RDN.Portable.Classes.League.Classes.League model) { try { var federation = MemberCache.GetAllOwnedFederations(RDN.Library.Classes.Account.User.GetMemberId()).FirstOrDefault().Federation; Federation.DisconnectLeagueFromFederation(federation.FederationId, model.LeagueId); return RedirectToAction("ViewLeagues"); } catch (Exception exception) { ErrorDatabaseManager.AddException(exception, GetType()); return RedirectToAction("ViewLeagues"); } }
public static bool UpdateTaskListInfo(RDN.Library.Classes.League.TaskList.TaskListDA ListToUpdate) { try { var dc = new ManagementContext(); var dbList = dc.TaskLists.Where(x => x.ListId == ListToUpdate.ListId).FirstOrDefault(); if (dbList == null) return false; dbList.AssignedTo = ListToUpdate.AssignedTo; dbList.EndDate = ListToUpdate.EndDate; dbList.ListAddByMember.MemberId = ListToUpdate.ListAddByMember; dbList.ListName = ListToUpdate.ListName; dbList.TaskListForLeague.LeagueId = ListToUpdate.TaskListForLeague; int c = dc.SaveChanges(); return c > 0; } catch (Exception exception) { ErrorDatabaseManager.AddException(exception, exception.GetType()); } return false; }
private void ParseDN(string dnString) { // If the string has nothing in it, that's allowed. Just return an empty array. if (dnString.Length == 0) { rDNs = new RDNList(new RDN[0]); return; // That was easy... } // Break the DN down into its component RDNs. // Don't check the validity of the RDNs; just find the separators. ArrayList rawRDNs = new ArrayList(); ParserState state = ParserState.LookingForSeparator; StringBuilder rawRDN = new StringBuilder(); for (int position = 0; position < dnString.Length; ++position) { switch(state) { # region case ParserState.LookingForSeparator: case ParserState.LookingForSeparator: // If we find a separator character, we've hit the end of an RDN. // We'll store the RDN, and we'll check to see if the RDN is actually // valid later. if (dnString[position] == ',' || dnString[position] == ';') { rawRDNs.Add(rawRDN.ToString()); // Add the string to the list of raw RDNs rawRDN.Length = 0; // Clear the StringBuilder to prepare for the next RDN } else { // Add the character to our temporary RDN string rawRDN.Append(dnString[position]); // If we find an escape character, store character that follows it, // but don't consider it as a possible separator character. If the // string ends with an escape character, that's bad, and we should // throw an exception if (dnString[position] == '\\') { try { rawRDN.Append(dnString[++position]); } catch (IndexOutOfRangeException) { throw new ArgumentException("Invalid DN: DNs aren't allowed to end with an escape character.", dnString); } } // If we find a quote, we'll change state so that we look for the closing quote // and ignore any separator characters within. else if (dnString[position] == '"') { state = ParserState.InQuotedString; } } break; # endregion # region case ParserState.InQuotedString: case ParserState.InQuotedString: // Store the character rawRDN.Append(dnString[position]); // You're allowed to escape special characters in a quoted string, but not required // to. But if there's an escaped quote, we need to take special care to make sure // that we don't mistake that for the end of the quoted string. if (dnString[position] == '\\') { try { rawRDN.Append(dnString[++position]); } catch (IndexOutOfRangeException) { throw new ArgumentException("Invalid DN: DNs aren't allowed to end with an escape character.", dnString); } } else if (dnString[position] == '"') state = ParserState.LookingForSeparator; break; # endregion } } // Take the last RDN and add it to the list rawRDNs.Add(rawRDN.ToString()); // Check parser's end state if (state == ParserState.InQuotedString) throw new ArgumentException("Invalid DN: Unterminated quoted string.", dnString); RDN[] results = new RDN[rawRDNs.Count]; for (int i = 0; i < results.Length; i++) { results[i] = new RDN(rawRDNs[i].ToString()); } rDNs = new RDNList(results); }