コード例 #1
0
        public static bl_GuestList_Result UpdateGuest(bl_GuestList info)
        {
            using (var metadata = DataAccess.getDesktopMetadata())
            {
                //Get original guest record
                var qGuest = (from row in metadata.db_User
                              where row.userID == info.userID
                              select row).FirstOrDefault();

                var item = qGuest;
                if (item == null)
                {
                    throw new NullReferenceException("No Guest found");
                }

                item.hasRSVPd    = info.hasRSVPd;
                item.isAttending = info.isAttending;

                metadata.SaveChanges();

                var result = new bl_GuestList_Result
                {
                    hasError = false
                };
                return(result);
            }
        }
コード例 #2
0
        public static bl_GuestList_Result Edit(bl_GuestList info)
        {
            using (var metadata = DataAccess.getDesktopMetadata())
            {
                //Get original guest record
                var qGuest = (from row in metadata.db_User
                              where row.userID == info.userID
                              select row).FirstOrDefault();

                //Check if their is a duplicate
                var qDuplicate = (from row in metadata.db_User
                                  where row.Email.ToLower().Trim() == info.Email.ToLower().Trim() &&
                                  row.userID != info.userID
                                  select row).FirstOrDefault();


                var item = qGuest;
                if (item == null)
                {
                    throw new NullReferenceException("No Guest found");
                }

                var duplicate = qDuplicate;
                if (duplicate == null)
                {
                    item.FirstName     = info.FirstName;
                    item.LastName      = info.LastName;
                    item.Email         = info.Email;
                    item.Cell          = info.Cell;
                    item.allowPlusOne  = info.allowPlusOne;
                    item.groupCoupleID = info.groupCoupleID;

                    metadata.SaveChanges();

                    var result = new bl_GuestList_Result
                    {
                        hasError = false
                    };
                    return(result);
                }
                else
                {
                    var result = new bl_GuestList_Result
                    {
                        hasError  = true,
                        ErrorText = "Email already exist for another Guest"
                    };
                    return(result);
                }
            }
        }
コード例 #3
0
        public static bl_GuestList_Result Add(bl_GuestList info)
        {
            using (var metadata = DataAccess.getDesktopMetadata())
            {
                var qDuplicate = (from row in metadata.db_User
                                  where row.Email.ToLower().Trim() == info.Email.ToLower().Trim()
                                  select row).FirstOrDefault();

                if (qDuplicate == null)
                {
                    var newGuest = new db_User
                    {
                        FirstName     = info.FirstName,
                        LastName      = info.LastName,
                        Email         = info.Email,
                        Cell          = info.Cell,
                        PasswordHash  = info.PasswordHash,
                        allowPlusOne  = info.allowPlusOne,
                        isPlusOne     = info.isPlusOne,
                        groupCoupleID = info.groupCoupleID,
                        isGuest       = info.isGuest,
                        isAdmin       = info.isAdmin,
                        hasRSVPd      = info.hasRSVPd,
                        isAttending   = info.isAttending,
                    };

                    metadata.db_User.Add(newGuest);
                    metadata.SaveChanges();

                    var result = new bl_GuestList_Result
                    {
                        hasError = false,
                    };
                    return(result);
                }
                else
                {
                    var result = new bl_GuestList_Result
                    {
                        hasError  = true,
                        ErrorText = "Email already exist for another Guest"
                    };
                    return(result);
                }
            }
        }