I have code in SQL that will take the length of a SMS message and tell me how many parts the message will be.
Messages <= 160 characters are one part.
Messages > 160 characters become multipart messages, each part will then contain 152 characters. Can somebody please help me figure out a decent algorithm to accomplish something similar to the following in C# (lambda and linq expressions are welcome):
select
(case
when (LEN(Message)<=160) then 1
when (LEN(Message)>160 and LEN(Message)<305) then 2
when (LEN(Message)>304 and LEN(Message)<457) then 3
when (LEN(Message)>456 and LEN(Message)<609) then 4
when (LEN(Message)>608 and LEN(Message)<761) then 5
when (LEN(Message)>760 and LEN(Message)<913) then 6
when (LEN(Message)>912 and LEN(Message)<1065) then 7
when (LEN(Message)>1064 and LEN(Message)<1217) then 8
when (LEN(Message)>1216 and LEN(Message)<1369) then 9
when (LEN(Message)>1368 and LEN(Message)<1521) then 10
else 'n'
end) as [Msg Parts]
from tblAuditLog