コード例 #1
0
        public ActionResult Edit(int id)
        {
            var restaurantuser = (RestaurantUser)Repository.Find(id);

            if (restaurantuser != null)
            {
                restaurantuser = MembershipService.GetUser(restaurantuser.UserGuid, false);
                if (restaurantuser != null && restaurantuser.UserRole >= UserBase.RestaurantUserRole.Employee)
                {
                    return(View(new UpdateEmployeeModel
                    {
                        Address = restaurantuser.Address,
                        MobileNumber = restaurantuser.MobileNumber.ToString(),
                        UserGuid = restaurantuser.UserGuid,
                        UserRole = (EmployeeUserRole)(int)restaurantuser.UserRole,
                        EmployeeName = restaurantuser.Name,
                    }));
                }
            }
            TempData[TempDataStringResuorce.ActionResultNotification] = new ActionResultNotification
            {
                Message = String.Format("The Employee {0}cannot be edited because he {1}", restaurantuser != null ? restaurantuser.Name + " " : "", restaurantuser != null ? "is a " + restaurantuser.UserRole : "does not Exist"),
                Result  = false,
                State   = ActionResultNotification.MessageState.Error
            };
            return(RedirectToAction("Index"));
        }
コード例 #2
0
        /// <summary>
        /// Gets user information from the data source based on the unique identifier for the membership user. Provides an option to update the last-activity date/time stamp for the user.
        /// </summary>
        /// <returns>
        /// A <see cref="T:System.Web.Security.MembershipUser"/> object populated with the specified user's information from the data source.
        /// </returns>
        /// <param name="providerUserKey">The unique identifier for the membership user to get information for.</param><param name="userIsOnline">true to update the last-activity date/time stamp for the user; false to return user information without updating the last-activity date/time stamp for the user.</param>
        public override MembershipUser GetUser(object providerUserKey, bool userIsOnline)
        {
            var restaurantresult = (RestaurantUser)null;
            var sqlresult        = (MembershipUser)null;

            // ReSharper disable ConditionIsAlwaysTrueOrFalse
            if (providerUserKey != null && (providerUserKey is Guid))
            // ReSharper restore ConditionIsAlwaysTrueOrFalse
            {
                sqlresult = base.GetUser(providerUserKey, userIsOnline);
                if (sqlresult != null)
                {
                    restaurantresult =
                        RestaurantUserRepository.UserBaseToRestaurantUser(UserRepository.Find((Guid)providerUserKey));
                }
            }

            if (restaurantresult != null)
            {
                restaurantresult = CombineResult(restaurantresult, sqlresult);
            }

            return(restaurantresult);
        }