Example #1
0
        public void UpdateJointID(string key, Service.HoldingPen account, int otherID)
        {
            ServiceDataContext db = new ServiceDataContext();

            account.JointHoldingPenID = otherID;
            db.SubmitChanges();
        }
Example #2
0
        public bool SendNewPassword(string key, string email)
        {
            if (!IsAuthValid(key))
            {
                return(false);
            }

            ServiceDataContext db = new ServiceDataContext();

            email = email.ToLower();

            var result = db.CRM_Persons.ToList().FirstOrDefault(c => !c.IsArchived && c.PrimaryEmail.ToLower() == email);

            if (result != null)
            {
                // reset code //

                result.TempCode = Code.Models.CRM_Person.GeneratePassword();

                db.SubmitChanges();

                // send email //

                var emailManager = new EmailManager(result.PrimaryEmail);

                emailManager.SendNewPassword(result.Firstname, result.PrimaryEmail, result.TempCode);
            }

            return(true);
        }
Example #3
0
        public bool SendAccount(string key, Service.HoldingPen account, InterestAnswer[] interests)
        {
            ServiceDataContext db = new ServiceDataContext();

            JavaScriptSerializer js = new JavaScriptSerializer();

            account.InterestObjects = js.Serialize(interests);

            if (account.Password == null)
            {
                account.Password = "";
            }

            db.HoldingPens.InsertOnSubmit(account);
            db.SubmitChanges();

            return(true);
        }
Example #4
0
        public bool UpdatePassword(string key, string email, string password)
        {
            if (!IsAuthValid(key))
            {
                return(false);
            }

            ServiceDataContext db = new ServiceDataContext();

            email = email.ToLower();

            var result = db.CRM_Persons.ToList().FirstOrDefault(c => !c.IsArchived && c.PrimaryEmail.ToLower() == email);

            if (result != null)
            {
                result.Password = password;
                db.SubmitChanges();
            }

            return(true);
        }
Example #5
0
        public string SyncCalendar(int ExternalEventID, string Name, DateTime startDate, int attendees, int total, bool UpdateAttendance, string ticketTypeName)
        {
            try
            {
                ServiceDataContext db = new ServiceDataContext();

                Service.CRM_Calendar calendarItem = db.CRM_Calendars.FirstOrDefault(f => f.ExternalEventID == ExternalEventID && startDate.Date == f.StartDateTime.Date);

                int CalendarTypeID = db.CRM_CalendarTypes.Single(s => s.FixedRef == (int)Code.Models.CRM_CalendarType.TypeList.Event).ID;

                bool addedNew = false;
                if (calendarItem == null)
                {
                    addedNew = true;

                    calendarItem = new Service.CRM_Calendar();
                    calendarItem.CancellationReason      = "";
                    calendarItem.CreatedByAdminID        = 1;
                    calendarItem.CRM_CalendarTypeID      = CalendarTypeID;
                    calendarItem.DateCancelled           = null;
                    calendarItem.DatePaid                = null;
                    calendarItem.Status                  = (byte)Code.Models.CRM_Calendar.StatusTypes.Confirmed;
                    calendarItem.ExternalEventID         = ExternalEventID;
                    calendarItem.InvoiceAddressID        = null;
                    calendarItem.InvoiceFirstname        = "";
                    calendarItem.InvoiceLastname         = "";
                    calendarItem.InvoiceTitle            = "";
                    calendarItem.IsCancelled             = false;
                    calendarItem.IsInvoiced              = false;
                    calendarItem.PONumber                = "";
                    calendarItem.PriceAgreed             = 0;
                    calendarItem.PriceType               = 0;
                    calendarItem.PrimaryContactReference = "";
                    calendarItem.PrivacyStatus           = (byte)Code.Models.CRM_Calendar.PrivacyTypes.Editable;
                    calendarItem.RequiresCatering        = false;
                    calendarItem.TargetReference         = "";

                    if (ExternalEventID == 91)
                    {
                        calendarItem.CRM_CalendarTypeID = db.CRM_CalendarTypes.Single(s => s.FixedRef == (int)Code.Models.CRM_CalendarType.TypeList.generic).ID;

                        calendarItem.StartDateTime = startDate.AddHours(9);
                        calendarItem.EndDateTime   = startDate.AddHours(17);
                    }
                    else
                    {
                        if (startDate.Hour == 0)
                        {
                            calendarItem.StartDateTime = startDate.AddHours(9);
                            calendarItem.EndDateTime   = startDate.AddHours(10);
                        }
                        else
                        {
                            calendarItem.StartDateTime = startDate;
                            calendarItem.EndDateTime   = startDate.AddHours(1);
                        }
                    }

                    db.CRM_Calendars.InsertOnSubmit(calendarItem);
                }

                if (!UpdateAttendance || addedNew)
                {
                    calendarItem.Taken = attendees;
                    calendarItem.Limit = total;
                }
                calendarItem.DisplayName = Name;

                db.SubmitChanges();

                if (UpdateAttendance)
                {
                    Service.CRM_AttendanceEvent attendanceEvent = db.CRM_AttendanceEvents.FirstOrDefault(f => f.ExternalEventID == ExternalEventID);

                    if (attendanceEvent == null)
                    {
                        attendanceEvent = new Service.CRM_AttendanceEvent()
                        {
                            ExternalEventID = ExternalEventID,
                            Name            = Name
                        };

                        db.CRM_AttendanceEvents.InsertOnSubmit(attendanceEvent);
                        db.SubmitChanges();
                    }

                    Service.CRM_AttendanceLogGroup group = new Service.CRM_AttendanceLogGroup();

                    group.CRM_AttendanceEventID = attendanceEvent.ID;
                    group.AddedTimeStamp        = startDate;
                    group.OriginType            = (byte)CRM.Code.Models.CRM_AttendanceLogGroup.OriginTypes.WebsiteWebservice;
                    group.DateInserted          = UKTime.Now;
                    db.CRM_AttendanceLogGroups.InsertOnSubmit(group);
                    db.SubmitChanges();

                    if (ticketTypeName.Length > 0)
                    {
                        string logticketType = "Web Booking - " + ticketTypeName;

                        Service.CRM_AttendancePersonType personType =
                            db.CRM_AttendancePersonTypes.FirstOrDefault(f => f.Name == logticketType);

                        if (personType == null)
                        {
                            personType            = new Service.CRM_AttendancePersonType();
                            personType.IsActive   = true;
                            personType.IsArchived = false;
                            personType.Name       = logticketType;
                            personType.OrderNo    = 0;
                            db.CRM_AttendancePersonTypes.InsertOnSubmit(personType);
                        }

                        db.SubmitChanges();

                        Service.CRM_AttendanceLog log = new Service.CRM_AttendanceLog();
                        log.CRM_AttendancePersonTypeID = personType.ID;
                        log.Quantity = attendees;
                        log.CRM_CRM_AttendanceLogGroupID = group.ID;
                        db.CRM_AttendanceLogs.InsertOnSubmit(log);
                        db.SubmitChanges();
                    }
                }

                return("OK");
            }
            catch (Exception ex) {
                var st = new StackTrace(ex, true);
                // Get the top stack frame
                var frame = st.GetFrame(0);
                // Get the line number from the stack frame
                var line = frame.GetFileLineNumber();

                return("External Event ID " + ExternalEventID + " : " + ex.Message + ":" + line);
            }
        }