internal static model.Buddy MakeEntityBuddy(contract.Buddy buddy, long ProfileID, bool updateState = true) { if (buddy == null) { return(null); } var buddyEntity = new model.Buddy { BuddyID = buddy.BuddyID, ProfileID = ProfileID, UserID = buddy.UserID, BuddyName = buddy.Name, MobileNumber = utility.Security.Encrypt(buddy.MobileNumber), Email = buddy.Email, IsPrimeBuddy = buddy.IsPrimeBuddy, SubscribtionId = buddy.SubscribtionID }; if (updateState) { buddyEntity.State = (model.BuddyState)buddy.State; } return(buddyEntity); }
public async Task <ResultInfo> AssignBuddyToMarshal(string AdminID, string groupID, string marshalProfileID, string marshalUserID, string targetUserProfileID) { int GroupID = Convert.ToInt32(groupID); long MarshalProfileID = Convert.ToInt64(marshalProfileID); long MarshalUserID = Convert.ToInt64(marshalUserID); long TargetUserProfileID = Convert.ToInt64(targetUserProfileID); var result = new ResultInfo(); try { if (string.IsNullOrEmpty(AdminID) || GroupID == 0 || MarshalProfileID == 0 || MarshalUserID == 0 || TargetUserProfileID == 0) { result.ResultType = ResultTypeEnum.Error; result.Message = "Marshal Not assigned Buddy List.Invalid IDs !"; } else if (MarshalValidationsForBuddy(AdminID, GroupID, MarshalProfileID, TargetUserProfileID, true)) { //right people fall under right places. model.User marshalUser = await _MemberRepository.GetUserByUserIDAsync(MarshalUserID); if (marshalUser != null) { var buddy = new model.Buddy { ProfileID = TargetUserProfileID, UserID = marshalUser.UserID, BuddyName = marshalUser.Name, MobileNumber = marshalUser.MobileNumber, Email = marshalUser.Email, State = model.BuddyState.Marshal, SubscribtionId = Guid.NewGuid() }; bool isBuddyAdded = await _MemberRepository.AddBuddyAsync(buddy); if (isBuddyAdded) { result.ResultType = ResultTypeEnum.Success; result.Message = "Marshal added as a Buddy !"; } } else { result.ResultType = ResultTypeEnum.Error; result.Message = "Marshal Not Added as a Buddy.Invalid MarshalUserIDs !"; } } else { result.ResultType = ResultTypeEnum.Error; result.Message = "Marshal Not Added as a Buddy.Invalid IDs !"; } } catch (Exception e) { result.ResultType = ResultTypeEnum.Exception; result.Message = "Failed-" + e.Message; } return(result); }